| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 8abcc76 commit 7be4a39
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,8 +14,7 @@ | |||
| 14 | 14 | ||
| 15 | 15 | // This file is compiled as if it's wrapped in a function with arguments | |
| 16 | 16 | // passed by node::LoadEnvironment() | |
| 17 | - /* global process, loaderExports, triggerFatalException */ | ||
| 18 | - /* global isMainThread */ | ||
| 17 | + /* global process, loaderExports, isMainThread */ | ||
| 19 | 18 | ||
| 20 | 19 | const { internalBinding, NativeModule } = loaderExports; | |
| 21 | 20 | ||
@@ -619,12 +618,12 @@ function setupGlobalEncoding() { | |||
| 619 | 618 | ||
| 620 | 619 | function setupQueueMicrotask() { | |
| 621 | 620 | Object.defineProperty(global, 'queueMicrotask', { | |
| 622 | - get: () => { | ||
| 621 | + get() { | ||
| 623 | 622 | process.emitWarning('queueMicrotask() is experimental.', | |
| 624 | 623 | 'ExperimentalWarning'); | |
| 625 | - const { setupQueueMicrotask } = | ||
| 624 | + const { queueMicrotask } = | ||
| 626 | 625 | NativeModule.require('internal/queue_microtask'); | |
| 627 | - const queueMicrotask = setupQueueMicrotask(triggerFatalException); | ||
| 626 | + | ||
| 628 | 627 | Object.defineProperty(global, 'queueMicrotask', { | |
| 629 | 628 | value: queueMicrotask, | |
| 630 | 629 | writable: true, | |
@@ -633,7 +632,7 @@ function setupQueueMicrotask() { | |||
| 633 | 632 | }); | |
| 634 | 633 | return queueMicrotask; | |
| 635 | 634 | }, | |
| 636 | - set: (v) => { | ||
| 635 | + set(v) { | ||
| 637 | 636 | Object.defineProperty(global, 'queueMicrotask', { | |
| 638 | 637 | value: v, | |
| 639 | 638 | writable: true, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,37 +3,36 @@ | |||
| 3 | 3 | const { ERR_INVALID_ARG_TYPE } = require('internal/errors').codes; | |
| 4 | 4 | const { AsyncResource } = require('async_hooks'); | |
| 5 | 5 | const { getDefaultTriggerAsyncId } = require('internal/async_hooks'); | |
| 6 | - const { enqueueMicrotask } = internalBinding('util'); | ||
| 6 | + const { | ||
| 7 | + enqueueMicrotask, | ||
| 8 | + triggerFatalException | ||
| 9 | + } = internalBinding('util'); | ||
| 7 | 10 | ||
| 8 | - const setupQueueMicrotask = (triggerFatalException) => { | ||
| 9 | - const queueMicrotask = (callback) => { | ||
| 10 | - if (typeof callback !== 'function') { | ||
| 11 | - throw new ERR_INVALID_ARG_TYPE('callback', 'function', callback); | ||
| 12 | - } | ||
| 11 | + function queueMicrotask(callback) { | ||
| 12 | + if (typeof callback !== 'function') { | ||
| 13 | + throw new ERR_INVALID_ARG_TYPE('callback', 'function', callback); | ||
| 14 | + } | ||
| 13 | 15 | ||
| 14 | - const asyncResource = new AsyncResource('Microtask', { | ||
| 15 | - triggerAsyncId: getDefaultTriggerAsyncId(), | ||
| 16 | - requireManualDestroy: true, | ||
| 17 | - }); | ||
| 16 | + const asyncResource = new AsyncResource('Microtask', { | ||
| 17 | + triggerAsyncId: getDefaultTriggerAsyncId(), | ||
| 18 | + requireManualDestroy: true, | ||
| 19 | + }); | ||
| 18 | 20 | ||
| 19 | - enqueueMicrotask(() => { | ||
| 20 | - asyncResource.runInAsyncScope(() => { | ||
| 21 | - try { | ||
| 22 | - callback(); | ||
| 23 | - } catch (error) { | ||
| 24 | - // TODO(devsnek) remove this if | ||
| 25 | - // https://bugs.chromium.org/p/v8/issues/detail?id=8326 | ||
| 26 | - // is resolved such that V8 triggers the fatal exception | ||
| 27 | - // handler for microtasks | ||
| 28 | - triggerFatalException(error); | ||
| 29 | - } finally { | ||
| 30 | - asyncResource.emitDestroy(); | ||
| 31 | - } | ||
| 32 | - }); | ||
| 21 | + enqueueMicrotask(() => { | ||
| 22 | + asyncResource.runInAsyncScope(() => { | ||
| 23 | + try { | ||
| 24 | + callback(); | ||
| 25 | + } catch (error) { | ||
| 26 | + // TODO(devsnek) remove this if | ||
| 27 | + // https://bugs.chromium.org/p/v8/issues/detail?id=8326 | ||
| 28 | + // is resolved such that V8 triggers the fatal exception | ||
| 29 | + // handler for microtasks | ||
| 30 | + triggerFatalException(error); | ||
| 31 | + } finally { | ||
| 32 | + asyncResource.emitDestroy(); | ||
| 33 | + } | ||
| 33 | 34 | }); | |
| 34 | - }; | ||
| 35 | - | ||
| 36 | - return queueMicrotask; | ||
| 37 | - }; | ||
| 35 | + }); | ||
| 36 | + } | ||
| 38 | 37 | ||
| 39 | - module.exports = { setupQueueMicrotask }; | ||
| 38 | + module.exports = { queueMicrotask }; | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1163,18 +1163,14 @@ void LoadEnvironment(Environment* env) { | |||
| 1163 | 1163 | return; | |
| 1164 | 1164 | } | |
| 1165 | 1165 | ||
| 1166 | - // process, bootstrappers, loaderExports, triggerFatalException | ||
| 1166 | + // process, loaderExports, isMainThread | ||
| 1167 | 1167 | std::vector<Local<String>> node_params = { | |
| 1168 | 1168 | env->process_string(), | |
| 1169 | 1169 | FIXED_ONE_BYTE_STRING(isolate, "loaderExports"), | |
| 1170 | - FIXED_ONE_BYTE_STRING(isolate, "triggerFatalException"), | ||
| 1171 | 1170 | FIXED_ONE_BYTE_STRING(isolate, "isMainThread")}; | |
| 1172 | 1171 | std::vector<Local<Value>> node_args = { | |
| 1173 | 1172 | process, | |
| 1174 | 1173 | loader_exports.ToLocalChecked(), | |
| 1175 | - env->NewFunctionTemplate(FatalException) | ||
| 1176 | - ->GetFunction(context) | ||
| 1177 | - .ToLocalChecked(), | ||
| 1178 | 1174 | Boolean::New(isolate, env->is_main_thread())}; | |
| 1179 | 1175 | ||
| 1180 | 1176 | if (ExecuteBootstrapper( | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,5 @@ | |||
| 1 | 1 | #include "node_internals.h" | |
| 2 | + #include "node_errors.h" | ||
| 2 | 3 | #include "node_watchdog.h" | |
| 3 | 4 | ||
| 4 | 5 | namespace node { | |
@@ -221,7 +222,7 @@ void Initialize(Local<Object> target, | |||
| 221 | 222 | WatchdogHasPendingSigint); | |
| 222 | 223 | ||
| 223 | 224 | env->SetMethod(target, "enqueueMicrotask", EnqueueMicrotask); | |
| 224 | - | ||
| 225 | + env->SetMethod(target, "triggerFatalException", FatalException); | ||
| 225 | 226 | Local<Object> constants = Object::New(env->isolate()); | |
| 226 | 227 | NODE_DEFINE_CONSTANT(constants, ALL_PROPERTIES); | |
| 227 | 228 | NODE_DEFINE_CONSTANT(constants, ONLY_WRITABLE); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments