Merge remote-tracking branch 'origin/fibers-optional-no-tla-pkgs' into fibers-optional-no-tla-pkgs

This commit is contained in:
Matheus Castro
2022-12-10 00:53:58 -03:00
12 changed files with 51 additions and 51 deletions

View File

@@ -19,7 +19,8 @@ let Fiber;
let Future;
if (Meteor.isServer) {
Fiber = Npm.require('fibers');
Future = Npm.require('fibers/future');
// TODO Review fiber use
Future = Meteor._isFibersEnabled ? Npm.require('fibers/future') : null;
}
class MongoIDMap extends IdMap {

View File

@@ -34,7 +34,8 @@ Meteor.methods({
// We used to improperly serialize errors that were thrown through a
// future first.
if (Meteor.isServer && options.throwThroughFuture) {
// TODO Review fiber use
if (Meteor.isServer && options.throwThroughFuture && Meteor._isFibersEnabled) {
const Future = Npm.require('fibers/future');
const f = new Future();
f['throw'](e);
@@ -59,7 +60,8 @@ if (Meteor.isServer) {
// other.
const waiters = Object.create(null);
const Future = Npm.require('fibers/future');
// TODO Review fiber use
const Future = Meteor._isFibersEnabled ? Npm.require('fibers/future') : null;
const returnThroughFuture = function(token, returnValue) {
// Make sure that when we call return, the fields are already cleared.

View File

@@ -17,7 +17,8 @@ import {
let Fiber;
let Future;
if (Meteor.isServer) {
// TODO Review fiber use
if (Meteor.isServer && Meteor._isFibersEnabled) {
Fiber = Npm.require('fibers');
Future = Npm.require('fibers/future');
}

View File

@@ -9,11 +9,6 @@ Npm.depends({
});
Package.onUse((api) => {
if (process.env.DISABLE_FIBERS) {
api.use('ddp-client-async');
api.export('DDP', 'server');
return;
}
api.use([
'check',
'random',

View File

@@ -1,4 +1,5 @@
var Future = Npm.require('fibers/future');
// TODO Review fiber use
var Future = Meteor._isFibersEnabled ? Npm.require('fibers/future') : null;
// A write fence collects a group of writes, and provides a callback
// when all of the writes are fully committed and propagated (all

View File

@@ -1,7 +1,8 @@
const stylus = Npm.require('stylus');
const nib = Npm.require('nib');
const autoprefixer = Npm.require('autoprefixer-stylus');
const Future = Npm.require('fibers/future');
// TODO Review fiber use
const Future = Meteor._isFibersEnabled ? Npm.require('fibers/future') : null;
const fs = Plugin.fs;
const path = Plugin.path;

View File

@@ -1,5 +1,3 @@
var Fiber = Npm.require('fibers');
var Future = Npm.require('fibers/future');
Meteor._noYieldsAllowed = function (f) {
return f();

View File

@@ -1,4 +1,6 @@
if (Meteor.isServer)
// TODO Review fiber use
if (Meteor.isServer && Meteor._isFibersEnabled)
var Future = Npm.require('fibers/future');
if (typeof __meteor_runtime_config__ === 'object' &&

View File

@@ -2170,8 +2170,8 @@ main.registerCommand({
email: { type: Boolean }
},
catalogRefresh: new catalog.Refresh.Never()
}, function (options) {
return auth.loginCommand(Object.assign({
}, async function (options) {
return await auth.loginCommand(Object.assign({
overwriteExistingToken: true
}, options));
});

View File

@@ -149,7 +149,6 @@
// wait until later.
var assert = require('assert');
var Fiber = require('fibers');
var _ = require('underscore');
var compiler = require('./compiler.js');

View File

@@ -10,16 +10,16 @@ var Console = require('../console/console.js').Console;
var auth = exports;
function loadDDP() {
return require("../tool-env/isopackets.js")
.loadIsopackage("ddp-client")
.DDP;
async function loadDDP() {
const isopackage = require("../tool-env/isopackets.js");
const { DDP } = await isopackage.loadIsopackage("ddp-client");
return DDP;
}
// Opens and returns a DDP connection to the accounts server. Remember
// to close it when you're done with it!
var openAccountsConnection = function () {
return loadDDP().connect(config.getAuthDDPUrl(), {
var openAccountsConnection = async function () {
return (await loadDDP()).connect(config.getAuthDDPUrl(), {
headers: { 'User-Agent': httpHelpers.getUserAgent() }
});
};
@@ -28,9 +28,9 @@ var openAccountsConnection = function () {
// that is a connection to the accounts server, which gets closed when
// `f` returns or throws.
var withAccountsConnection = function (f) {
return function (...args) {
return async function (...args) {
var self = this;
var conn = openAccountsConnection();
var conn = await openAccountsConnection();
args.push(conn);
try {
var result = f.apply(self, args);
@@ -47,7 +47,7 @@ var withAccountsConnection = function (f) {
// XXX if we reconnect we won't reauthenticate. Fix that before using
// this for long-lived connections.
var loggedInAccountsConnection = async function (token) {
var connection = loadDDP().connect(
var connection = (await loadDDP()).connect(
config.getAuthDDPUrl()
);
@@ -91,13 +91,13 @@ var loggedInAccountsConnection = async function (token) {
// provided, one will be opened and then closed before returning.
var sessionMethodCaller = function (methodName, options) {
options = options || {};
return function (...args) {
return async function (...args) {
args.push({
session: auth.getSessionId(config.getAccountsDomain()) || null
});
var timer;
var conn = options.connection || openAccountsConnection();
var conn = options.connection || await openAccountsConnection();
function cleanUp() {
timer && clearTimeout(timer);
@@ -289,7 +289,7 @@ var removePendingRevoke = function (domain, tokenIds) {
// session. just changes the error message.
// - connection: an open connection to the accounts server. If not
// provided, this function will open one itself.
var tryRevokeOldTokens = function (options) {
var tryRevokeOldTokens = async function (options) {
options = Object.assign({
timeout: 5000
}, options || {});
@@ -313,8 +313,7 @@ var tryRevokeOldTokens = function (options) {
warned = true;
}
};
_.each(domainsWithRevokedTokens, function (domain) {
for (const domain in domainsWithRevokedTokens) {
var data = readSessionData();
var session = data.sessions[domain] || {};
var tokenIds = session.pendingRevoke || [];
@@ -327,7 +326,7 @@ var tryRevokeOldTokens = function (options) {
if (session.type === "meteor-account") {
try {
sessionMethodCaller('revoke', {
await sessionMethodCaller('revoke', {
timeout: options.timeout,
connection: options.connection
})(tokenIds);
@@ -346,7 +345,7 @@ var tryRevokeOldTokens = function (options) {
logoutFailWarning(domain);
return;
}
});
}
};
var sendAuthorizeRequest = function (clientId, redirectUri, state) {
@@ -457,7 +456,7 @@ var oauthFlow = function (conn, options) {
// error message to stderr if the login fails
// - connection: an open connection to the accounts server. If not
// provided, this function will open its own connection.
var doInteractivePasswordLogin = function (options) {
var doInteractivePasswordLogin = async function (options) {
var loginData = {};
if (_.has(options, 'username')) {
@@ -478,7 +477,7 @@ var doInteractivePasswordLogin = function (options) {
}
};
var conn = options.connection || openAccountsConnection();
var conn = options.connection || await openAccountsConnection();
var maybeCloseConnection = function () {
if (! options.connection) {
@@ -576,7 +575,7 @@ exports.loginCommand = withAccountsConnection(async function (options,
loginOptions.connection = connection;
if (! doInteractivePasswordLogin(loginOptions)) {
if (! await doInteractivePasswordLogin(loginOptions)) {
return 1;
}
}

View File

@@ -1,7 +1,7 @@
var Fiber = require("fibers");
// var Fiber = require("fibers");
var fs = require("fs");
var path = require("path");
var Future = require("fibers/future");
//var Future = require("fibers/future");
var sourcemap_support = require('source-map-support');
var bootUtils = require('./boot-utils.js');
@@ -52,8 +52,9 @@ if (!process.env.APP_ID) {
// Map from load path to its source map.
var parsedSourceMaps = {};
// TODO Review fiber use
const meteorDebugFuture =
process.env.METEOR_INSPECT_BRK ? new Future : null;
process.env.METEOR_INSPECT_BRK ? null : null;
function maybeWaitForDebuggerToAttach() {
if (meteorDebugFuture) {
@@ -75,7 +76,7 @@ function maybeWaitForDebuggerToAttach() {
`Debugger did not attach after ${waitLimitMinutes} minutes; continuing.`
);
meteorDebugFuture.return();
//meteorDebugFuture.return();
} else {
// This pause function contains a debugger keyword that will only
@@ -95,7 +96,7 @@ function maybeWaitForDebuggerToAttach() {
// time, we can conclude the debugger keyword must be active,
// which means a debugging client must be connected, which means
// we should stop polling and let the main Fiber continue.
meteorDebugFuture.return();
//meteorDebugFuture.return();
} else {
// If the pause() function call didn't take a meaningful amount
@@ -108,7 +109,7 @@ function maybeWaitForDebuggerToAttach() {
}, pollIntervalMs);
// The polling will continue while we wait here.
meteorDebugFuture.wait();
//meteorDebugFuture.wait();
}
}
@@ -311,8 +312,8 @@ var loadServerBundles = Profile("Load server bundles", function () {
var getAsset = function (assetPath, encoding, callback) {
var fut;
if (! callback) {
fut = new Future();
callback = fut.resolver();
//fut = new Future();
//callback = fut.resolver();
}
// This assumes that we've already loaded the meteor package, so meteor
// itself can't call Assets.get*. (We could change this function so that
@@ -499,12 +500,12 @@ function startServerProcess() {
});
}
if (IS_FIBERS_ENABLED) {
Fiber(function() {
startServerProcess();
}).run();
return;
} else {
// if (IS_FIBERS_ENABLED) {
// Fiber(function() {
// startServerProcess();
// }).run();
// return;
// } else {
startServerProcess();
}
//}