Skip to content

Commit

Permalink
fix: wait for repl to close
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Steblyuk committed Jul 22, 2021
1 parent bebec16 commit 5b1f73a
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/debug-async-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,23 @@ export function createDebugAsyncNode(
createDebuggerAPI(bindings, apiNamespace, logger)
);
const repl = startRepl(replOptions);
repl.once('exit', api.resumeExecution);
const exitPromise = new Promise<void>((resolve) => {
repl.once('exit', () => {
api.resumeExecution();
resolve();
});
});
const teardown = applyToContexts([...contexts, repl.context]);

try {
isBeingDebugged = true;
return await resultPromise;
const result = await resultPromise;
return result;
} finally {
isBeingDebugged = false;
repl.close();
teardown();
repl.close();
await exitPromise;
isBeingDebugged = false;
}
};
}

0 comments on commit 5b1f73a

Please sign in to comment.