bare-module 3.1.14 → 3.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/binding.c +14 -12
- package/index.js +8 -4
- package/package.json +1 -1
- package/prebuilds/darwin-arm64/bare-module.bare +0 -0
- package/prebuilds/darwin-x64/bare-module.bare +0 -0
- package/prebuilds/linux-arm64/bare-module.bare +0 -0
- package/prebuilds/linux-x64/bare-module.bare +0 -0
- package/prebuilds/win32-x64/bare-module.bare +0 -0
package/binding.c
CHANGED
|
@@ -474,28 +474,30 @@ bare_module_run_module (js_env_t *env, js_callback_info_t *info) {
|
|
|
474
474
|
err = js_get_promise_state(env, promise, &state);
|
|
475
475
|
assert(err == 0);
|
|
476
476
|
|
|
477
|
+
js_value_t *reason;
|
|
478
|
+
|
|
477
479
|
if (state == js_promise_rejected) {
|
|
478
|
-
js_value_t *reason;
|
|
479
480
|
err = js_get_promise_result(env, promise, &reason);
|
|
480
481
|
if (err < 0) return NULL;
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
err = js_get_and_clear_last_exception(env, &exception);
|
|
482
|
+
} else {
|
|
483
|
+
err = js_get_null(env, &reason);
|
|
484
484
|
assert(err == 0);
|
|
485
|
+
}
|
|
485
486
|
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
487
|
+
js_value_t *exception;
|
|
488
|
+
err = js_get_and_clear_last_exception(env, &exception);
|
|
489
|
+
assert(err == 0);
|
|
489
490
|
|
|
490
|
-
|
|
491
|
+
js_value_t *ctx;
|
|
492
|
+
err = js_get_reference_value(env, context->ctx, &ctx);
|
|
493
|
+
assert(err == 0);
|
|
491
494
|
|
|
492
|
-
|
|
495
|
+
js_value_t *args[3] = {reason, promise, exception};
|
|
493
496
|
|
|
494
|
-
|
|
495
|
-
}
|
|
497
|
+
js_call_function(env, ctx, argv[2], 3, args, NULL);
|
|
496
498
|
}
|
|
497
499
|
|
|
498
|
-
return
|
|
500
|
+
return NULL;
|
|
499
501
|
}
|
|
500
502
|
|
|
501
503
|
static js_value_t *
|
package/index.js
CHANGED
|
@@ -180,7 +180,7 @@ const Module = module.exports = exports = class Module {
|
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
_run () {
|
|
183
|
-
binding.runModule(this._handle, Module._handle, Module.
|
|
183
|
+
binding.runModule(this._handle, Module._handle, Module._onrun)
|
|
184
184
|
}
|
|
185
185
|
|
|
186
186
|
_evaluate (eagerRun = false) {
|
|
@@ -343,10 +343,14 @@ const Module = module.exports = exports = class Module {
|
|
|
343
343
|
}
|
|
344
344
|
}
|
|
345
345
|
|
|
346
|
-
static
|
|
347
|
-
|
|
346
|
+
static _onrun (reason, promise, err = reason) {
|
|
347
|
+
if (err) {
|
|
348
|
+
promise.catch(() => {}) // Don't leak the rejection
|
|
348
349
|
|
|
349
|
-
|
|
350
|
+
throw err
|
|
351
|
+
} else {
|
|
352
|
+
promise.catch((err) => queueMicrotask(() => { throw err }))
|
|
353
|
+
}
|
|
350
354
|
}
|
|
351
355
|
|
|
352
356
|
static Protocol = Protocol
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|