Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Profiler in --inspect doesn't support worker threads #17537

Open
CarelessParsley opened this issue Feb 22, 2025 · 0 comments
Open

Profiler in --inspect doesn't support worker threads #17537

CarelessParsley opened this issue Feb 22, 2025 · 0 comments
Labels
bug Something isn't working needs triage

Comments

@CarelessParsley
Copy link

What version of Bun is running?

1.2.2+c1708ea6a

What platform is your computer?

Darwin 24.3.0 arm64 arm

What steps can reproduce the bug?

I assume that it should be easy to construct a simplified repro: setup a workerpool using 'workerpool', have the worker do some compute, and then bun --inspect, turn on recording, and then observe no samples show up.

The full repro with the actual app in question involves:

  1. Install https://github.com/nerolis-lab/nerolis-lab per the instructions; you need the backend but having the frontend too is convenient for sending a request
  2. In backend/, run bun --inspect --watch src/app.ts
  3. Turn on timeline recording in the inspect page
  4. Send a request to backend

Expectation: worker compute shows up in profile
Actual: No compute shows up at all

You can then show that this is indeed due to the worker by patching the server with

diff --git a/backend/src/routes/calculator-router/production-router.ts b/backend/src/routes/calculator-router/production-router.ts
index 4e5526e..599888c 100644
--- a/backend/src/routes/calculator-router/production-router.ts
+++ b/backend/src/routes/calculator-router/production-router.ts
@@ -1,6 +1,7 @@
 import type { MaybeAuthenticatedRequest } from '@src/middleware/authorization-middleware.js';
 import { withMaybeUser } from '@src/middleware/authorization-middleware.js';
 import { BaseRouter } from '@src/routes/base-router.js';
+import { calculateTeam } from '@src/services/worker/calculator-worker.js';
 import { calculatorPool } from '@src/services/worker/worker-pool.js';
 import type { Request, Response } from 'express';
 import {
@@ -48,7 +49,8 @@ class ProductionRouterImpl {
 
           const user = (req as MaybeAuthenticatedRequest).user;
 
-          const data = await calculatorPool.exec('calculateTeam', [req.body, user]);
+          //const data = await calculatorPool.exec('calculateTeam', [req.body, user]);
+          const data = await calculateTeam(req.body, user);
 
           res.json(data);
         } catch (err) {

And now your profile lights up if you do the same again.

What is the expected behavior?

No response

What do you see instead?

No response

Additional information

No response

@CarelessParsley CarelessParsley added bug Something isn't working needs triage labels Feb 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage
Projects
None yet
Development

No branches or pull requests

1 participant