node/test/parallel/test-promise-unhandled-error-with-reading-file.js
Shima Ryuhei 60f1a5d077
process: fix wrong asyncContext under unhandled-rejections=strict
Fixes: https://github.com/nodejs/node/issues/60034
PR-URL: https://github.com/nodejs/node/pull/60103
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
2025-10-04 02:12:19 +00:00

30 lines
505 B
JavaScript

// Flags: --unhandled-rejections=strict
'use strict';
const common = require('../common');
const fs = require('fs');
const assert = require('assert');
process.on('unhandledRejection', common.mustNotCall);
process.on('uncaughtException', common.mustCall((err) => {
assert.ok(err.message.includes('foo'));
}));
async function readFile() {
return fs.promises.readFile(__filename);
}
async function crash() {
throw new Error('foo');
}
async function main() {
crash();
readFile();
}
main();