Mailspring/packages/client-app/spec/n1-spec-runner/spec-bootstrap.es6
Evan Morikawa 53465515b0 [client-app] replace setImmediate with setTimeout as Promise scheduler
Summary:
This changes the scheduler from `setImmediate` to `setTimeout`. The HUGE
difference is that Chrome's async stack traces works with `setTimeout` but
does NOT work with `setImmediate`. These two functions are adjacent to
each other in the Node event loop, so nothing should depend on the change
in ordering.

Test Plan: manual

Reviewers: mark, spang, halla, juan

Reviewed By: spang, halla

Differential Revision: https://phab.nylas.com/D4068
2017-03-01 12:16:54 -08:00

20 lines
744 B
JavaScript

/* eslint import/first: 0 */
// Swap out Node's native Promise for Bluebird, which allows us to
// do fancy things like handle exceptions inside promise blocks
global.Promise = require('bluebird');
const timeout = global.setTimeout;
Promise.setScheduler((fn) => timeout(fn, 0));
Promise.config({longStackTraces: true});
import NylasEnvConstructor from '../../src/nylas-env';
window.NylasEnv = NylasEnvConstructor.loadOrCreate();
NylasEnv.initialize();
const loadSettings = NylasEnv.getLoadSettings();
// This must be `required` instead of imported because
// NylasEnv.initialize() must complete before `nylas-exports` and other
// globals are available for import via es6 modules.
require('./n1-spec-runner').default.runSpecs(loadSettings)