| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 1bc0c1f commit 44ea525
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3727,7 +3727,16 @@ void LoadEnvironment(Environment* env) { | |||
| 3727 | 3727 | // who do not like how bootstrap_node.js sets up the module system but do | |
| 3728 | 3728 | // like Node's I/O bindings may want to replace 'f' with their own function. | |
| 3729 | 3729 | Local<Value> arg = env->process_object(); | |
| 3730 | - f->Call(Null(env->isolate()), 1, &arg); | ||
| 3730 | + auto ret = f->Call(env->context(), Null(env->isolate()), 1, &arg); | ||
| 3731 | + // If there was an error during bootstrap then it was either handled by the | ||
| 3732 | + // FatalException handler or it's unrecoverable (e.g. max call stack | ||
| 3733 | + // exceeded). Either way, clear the stack so that the AsyncCallbackScope | ||
| 3734 | + // destructor doesn't fail on the id check. | ||
| 3735 | + // There are only two ways to have a stack size > 1: 1) the user manually | ||
| 3736 | + // called MakeCallback or 2) user awaited during bootstrap, which triggered | ||
| 3737 | + // _tickCallback(). | ||
| 3738 | + if (ret.IsEmpty()) | ||
| 3739 | + env->async_hooks()->clear_async_id_stack(); | ||
| 3731 | 3740 | } | |
| 3732 | 3741 | ||
| 3733 | 3742 | static void PrintHelp() { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,21 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + require('../common'); | ||
| 4 | + | ||
| 5 | + if (process.argv[2] === 'async') { | ||
| 6 | + async function fn() { | ||
| 7 | + fn(); | ||
| 8 | + throw new Error(); | ||
| 9 | + } | ||
| 10 | + (async function() { await fn(); })(); | ||
| 11 | + // While the above should error, just in case it dosn't the script shouldn't | ||
| 12 | + // fork itself indefinitely so return early. | ||
| 13 | + return; | ||
| 14 | + } | ||
| 15 | + | ||
| 16 | + const assert = require('assert'); | ||
| 17 | + const { spawnSync } = require('child_process'); | ||
| 18 | + | ||
| 19 | + const ret = spawnSync(process.execPath, [__filename, 'async']); | ||
| 20 | + assert.strictEqual(ret.status, 0); | ||
| 21 | + assert.ok(!/async.*hook/i.test(ret.stderr.toString('utf8', 0, 1024))); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments