mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-02 07:43:42 +08:00
A host callback marks where it runs on Node's stack, and a call into Node.js from a fiber starts below that mark. Runtime code the callback runs may go deeper on Node's stack before it starts or resumes a fiber, and those frames stay live while the fiber runs: a call into Node.js from the fiber overwrote them. scr_switch now reports where it leaves Node's stack, and the mark moves down to it for the rest of the callback. 6823 runs a timer callback 200 frames deep that starts an async function calling into Node.js before its first await.
9 lines
190 B
JavaScript
9 lines
190 B
JavaScript
// Returns its argument after using some of Node's stack.
|
|
function down(n, depth) {
|
|
return depth === 0 ? n : down(n, depth - 1);
|
|
}
|
|
|
|
exports.echo = function (n) {
|
|
return down(n, 500);
|
|
};
|