0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-24 20:29:23 +01:00
nodejs/test/parallel/test-promise-unhandled-issue-43655.js
Aras Abbasi be8d64ec14
process: improve event-loop
PR-URL: https://github.com/nodejs/node/pull/52108
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2024-05-06 20:16:22 +00:00

28 lines
522 B
JavaScript

'use strict';
require('../common');
const assert = require('assert');
function delay(time) {
return new Promise((resolve) => {
setTimeout(resolve, time);
});
}
async function test() {
for (let i = 0; i < 100000; i++) {
await new Promise((resolve, reject) => {
reject('value');
})
.then(() => { }, () => { });
}
const time0 = Date.now();
await delay(0);
const diff = Date.now() - time0;
assert.ok(Date.now() - time0 < 500, `Expected less than 500ms, got ${diff}ms`);
}
test();