aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bun.js/async_hooks.exports.js12
-rw-r--r--test/bun.js/third-party/body-parser-test/express-body-parser-test.test.ts5
2 files changed, 14 insertions, 3 deletions
diff --git a/src/bun.js/async_hooks.exports.js b/src/bun.js/async_hooks.exports.js
index 1b5664bc2..055159934 100644
--- a/src/bun.js/async_hooks.exports.js
+++ b/src/bun.js/async_hooks.exports.js
@@ -145,11 +145,19 @@ class AsyncResource {
constructor(type, triggerAsyncId) {
this.type = type;
this.triggerAsyncId = triggerAsyncId;
+
+ if (AsyncResource.allowedRunInAsyncScope.has(type)) {
+ this.runInAsyncScope = this.#runInAsyncScope;
+ }
}
type;
triggerAsyncId;
+ // We probably will not fully support AsyncResource
+ // But some packages in the wild do depend on it
+ static allowedRunInAsyncScope = new Set(["prisma-client-request"]);
+
emitBefore() {
return true;
}
@@ -160,7 +168,9 @@ class AsyncResource {
emitDestroy() {}
- runInAsyncScope(fn, ...args) {
+ runInAsyncScope;
+
+ #runInAsyncScope(fn, ...args) {
notImplemented();
var result, err;
process.nextTick(fn => {
diff --git a/test/bun.js/third-party/body-parser-test/express-body-parser-test.test.ts b/test/bun.js/third-party/body-parser-test/express-body-parser-test.test.ts
index 8e0523b7c..1f95b318e 100644
--- a/test/bun.js/third-party/body-parser-test/express-body-parser-test.test.ts
+++ b/test/bun.js/third-party/body-parser-test/express-body-parser-test.test.ts
@@ -28,6 +28,7 @@ test("httpServer", async done => {
const httpServer = require("http").createServer(app);
app.on("error", err => {
+ console.error(err);
done(err);
});
app.use(json());
@@ -50,9 +51,9 @@ test("httpServer", async done => {
"Content-Type": "application/json",
},
});
-
- expect(resp.status).toBe(200);
expect(await resp.text()).toBe("POST - pong");
+ expect(resp.status).toBe(200);
+
expect(reached).toBe(true);
done();
});