Use __meteor_bootstrap__ to check if fibers enabled

This commit is contained in:
zodern
2023-03-03 17:07:23 -06:00
parent 7f2e18ecb4
commit ae49aa44bb
5 changed files with 24 additions and 6 deletions

View File

@@ -1,3 +1,5 @@
Meteor.fibersDisabled = true;
Meteor._isPromise = (r) => {
return r && typeof r.then === 'function';
};

View File

@@ -2,7 +2,9 @@ const getAslStore = () => (Meteor.isServer && global?.asyncLocalStorage?.getStor
const getValueFromAslStore = key => getAslStore()[key];
const updateAslStore = (key, value) => getAslStore()[key] = value;
Meteor._isFibersEnabled = !process.env.DISABLE_FIBERS && Meteor.isServer;
Meteor.fibersDisabled = !!__meteor_bootstrap__.fibersDisabled;
Meteor._isFibersEnabled = !Meteor.fibersDisabled;
Meteor._getAslStore = getAslStore;
Meteor._getValueFromAslStore = getValueFromAslStore;
Meteor._updateAslStore = updateAslStore;

View File

@@ -472,8 +472,19 @@ Object.assign(Isopack.prototype, {
// case right.)
}, async function () {
// Make a new Plugin API object for this plugin.
var Plugin = self._makePluginApi(name);
await plugin.load({ Plugin: Plugin, Profile: Profile });
const Plugin = self._makePluginApi(name);
const __meteor_bootstrap__ = {
fibersDisabled: true,
// Set to null to tell Meteor.startup to call hooks immediately
// XXX: should we fully support startup hooks in build plugins?
startupHooks: null
};
await plugin.load({
Plugin,
Profile,
__meteor_bootstrap__
});
});
}

View File

@@ -33,7 +33,8 @@ var starJson = JSON.parse(fs.readFileSync(path.join(buildDir, "star.json")));
__meteor_bootstrap__ = {
startupHooks: [],
serverDir: serverDir,
configJson: configJson
configJson: configJson,
fibersDisabled: true
};
__meteor_runtime_config__ = {
@@ -504,4 +505,3 @@ var runMain = Profile("Run main()", async function () {
});
});
})().catch(e => console.log('error on boot.js', e));

View File

@@ -303,7 +303,10 @@ var loadIsopacketFromDisk = async function (isopacketName) {
// An incredibly minimalist version of the environment from
// tools/server/boot.js. Kind of a hack.
var env = {
__meteor_bootstrap__: { startupHooks: [] },
__meteor_bootstrap__: {
startupHooks: [],
fibersDisabled: true
},
__meteor_runtime_config__: { meteorRelease: "ISOPACKET" }
};
env.Profile = Profile;