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

🐛 BUG: Wrangler hangs when recording profile in Chrome inspector #4409

Closed
ericmatthys opened this issue Nov 8, 2023 · 13 comments
Closed
Assignees
Labels
blocked Blocked on other work bug Something that isn't working

Comments

@ericmatthys
Copy link

ericmatthys commented Nov 8, 2023

Which Cloudflare product(s) does this pertain to?

Pages

What version(s) of the tool(s) are you using?

wrangler 3.15.0

What version of Node are you using?

18.16.0

What operating system are you using?

macOS Sonoma 14.1

Describe the Bug

Using the Chrome inspector, I have tried recording a profile both through the Performance tab as well as the deprecated Profiler tab (https://developer.chrome.com/blog/new-in-devtools-114/#js-profiler). After I click to start recording, I'll make a request to a worker / pages function, but the request hangs and never responds. If I try to stop recording in the Chrome inspector, that also seems to hang forever.

  • I have tried this in Chrome 120 (Beta) and 121 (Canary). For some reason the stable channel wasn't discovering wrangler in chrome://inspect.
  • If I start recording and stop without ever making a request to the worker / pages function, then it behaves normally.
  • I do not have any debugger; statements that might be interfering.
  • If I never try to record and make a request with the inspector open, I do see logs in the console from the pages function and it responds correctly.

Let me know what I can do to help track down this issue as it seems impossible to record a CPU profile right now to diagnose some performance issues.

Screenshot 2023-11-08 at 4 23 22 PM

Please provide a link to a minimal reproduction

No response

Please provide any relevant error logs

No response

@ericmatthys ericmatthys added the bug Something that isn't working label Nov 8, 2023
@penalosa
Copy link
Contributor

penalosa commented Nov 9, 2023

Have you tried this with Wrangler's hosted devtools? (Run wrangler dev and press d)

@github-project-automation github-project-automation bot moved this to Untriaged in workers-sdk Nov 9, 2023
@penalosa penalosa added the awaiting reporter response Needs clarification or followup from OP label Nov 9, 2023
@ericmatthys
Copy link
Author

@admah admah added awaiting Cloudflare response Awaiting response from workers-sdk maintainer team and removed awaiting reporter response Needs clarification or followup from OP labels Nov 10, 2023
@mrbbot
Copy link
Contributor

mrbbot commented Nov 27, 2023

Hey! 👋 I wasn't able to reproduce this locally, using a worker that made 100 crypto.pbkdf2Sync('secret', 'salt', 100000, 64, 'sha512'); calls. Would you be able to try clear site data in the hosted devtools? Open devtools on the hosted devtools, click the Application tab, then Clear site data:
image

@mrbbot mrbbot added awaiting reporter response Needs clarification or followup from OP and removed awaiting Cloudflare response Awaiting response from workers-sdk maintainer team labels Nov 27, 2023
@ericmatthys
Copy link
Author

Sorry for the late reply. In the hosted devtools (https://devtools.devprod.cloudflare.dev/js_app?theme=systemPreferred&ws=127.0.0.1%3A9229%2Fws&debugger=true), I don't see an Application tab at all.

Screenshot 2023-12-07 at 9 46 44 AM

@mrbbot
Copy link
Contributor

mrbbot commented Dec 11, 2023

Ah apologies, you'll need to open Chrome's regular DevTools on our hosted DevTools... 😅 The Application tab should be visible there.

@ericmatthys
Copy link
Author

Ah thanks. After trying that and testing some more, I can profile some routes, but some specific ones seem to hang forever as described originally. I'll try to narrow down what's causing that. There's nothing obvious about those routes that stands out right now.

For the routes that do work, the profile seems incomplete. I feel like I'm holding something wrong. 😅

Screenshot 2023-12-11 at 9 51 00 AM Screenshot 2023-12-11 at 9 51 06 AM Screenshot 2023-12-11 at 9 51 36 AM

@lrapoport-cf lrapoport-cf added awaiting Cloudflare response Awaiting response from workers-sdk maintainer team and removed awaiting reporter response Needs clarification or followup from OP labels Dec 18, 2023
@mrbbot
Copy link
Contributor

mrbbot commented Jan 2, 2024

Hey again! Were you able to make any progress narrowing down what caused the hanging? For the incomplete profiles, could you try sending lots of requests to the routes? That should help build a better picture for those bottom two tables.

@mrbbot mrbbot added awaiting reporter response Needs clarification or followup from OP and removed awaiting Cloudflare response Awaiting response from workers-sdk maintainer team labels Jan 2, 2024
@ssollows
Copy link

ssollows commented Jan 12, 2024

Hey there, I was getting this exact same issue. I would try and profile my application spinup, and after one or two refreshes, it locks up. I moved over to my windows PC and it works no problem. Only seeing this issue on my Mac with the following specs:

Which Cloudflare product(s) does this pertain to?
Pages

What version(s) of the tool(s) are you using?
wrangler 3.22.4

What version of Node are you using?
18.17.1

What operating system are you using?
macOS Sonoma 14.1

One question I had was the self time is 0ms for each function, and the ms is added up beside program. is this how it is supposed to read? It is similar to @ericmatthys profile screenshots. I was expecting to see self time for each function called.

@lrapoport-cf lrapoport-cf added awaiting Cloudflare response Awaiting response from workers-sdk maintainer team and removed awaiting reporter response Needs clarification or followup from OP labels Jan 23, 2024
@petebacondarwin
Copy link
Contributor

@ssollows - it would be great if you were able to provide a reproduction that we could debug.
@ericmatthys - did you manage to make some progress?

@petebacondarwin petebacondarwin added awaiting reporter response Needs clarification or followup from OP needs reproduction Needs reproduction from OP and removed awaiting Cloudflare response Awaiting response from workers-sdk maintainer team labels Jan 29, 2024
@ericmatthys
Copy link
Author

ericmatthys commented Feb 9, 2024

Sorry for dropping off here. I finally got some time to come back to this.


For the incomplete profiles, it seems like the generic (program) still shows 100% of the time with everything else at 0%, regardless of how many times I spam the request. The (program) time is simply however long the profiler was recording.

Screenshot 2024-02-09 at 3 04 44 PM Screenshot 2024-02-09 at 3 03 15 PM Screenshot 2024-02-09 at 2 58 53 PM

Some of the routes that were hanging when the profiler was recording seem to be fixed. I can still reproduce hangs, but not on all the routes I could before.

Interestingly, I'm seeing this behavior...

  1. Start the dev server
  2. Make a request to one of the safe routes
  3. Open debugger
  4. Observe that the Start button to start recording a profile is enabled
  5. Close the debugger
  6. Make a request to one of the problem routes
  7. Open the debugger again
  8. Observe that the Start button is now disabled, without ever having started a recording

I can simplify that to just:

  1. Start the dev server
  2. Make a request to one of the problem routes
  3. Open the debugger
  4. Observe that the Start button is now disabled, without ever having started a recording

There's nothing obvious that differentiates the safe routes from the problem routes. I'm using Pages Functions so it all gets compiled into one worker. All the routes have more or less similar responsibilities (make subrequests, transform the data, return a response).

@petebacondarwin petebacondarwin added awaiting Cloudflare response Awaiting response from workers-sdk maintainer team and removed awaiting reporter response Needs clarification or followup from OP labels Feb 16, 2024
@mrbbot
Copy link
Contributor

mrbbot commented Mar 1, 2024

Hey! 👋 Thanks for the additional information. I was able to reproduce the (program) issue with just workerd and have opened a new issue to track this over there: cloudflare/workerd#1754. 👍 I don't think there's much we can do on the wrangler side to fix this.

@mrbbot mrbbot added blocked Blocked on other work and removed awaiting Cloudflare response Awaiting response from workers-sdk maintainer team labels Mar 1, 2024
@mhart
Copy link
Contributor

mhart commented May 13, 2024

I'm seeing both these issues (the hanging, as well as the (program) issue). Seems relatively easy to reproduce with a Next.js app that's making concurrent requests, esp from pre-fetch.

CPU Profiling seems completely broken atm.

@andyjessop andyjessop moved this from Untriaged to Other in workers-sdk Jun 10, 2024
@penalosa
Copy link
Contributor

The fix for this should be released in the next version of Wrangler

@github-project-automation github-project-automation bot moved this from Other to Done in workers-sdk Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked Blocked on other work bug Something that isn't working
Projects
Archived in project
Development

No branches or pull requests

8 participants