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 pages dev die after waking up from sleep, and need to be manually restarted #2476

Closed
yw662 opened this issue Jan 1, 2023 · 3 comments
Labels
bug Something that isn't working

Comments

@yw662
Copy link

yw662 commented Jan 1, 2023

What version of Wrangler are you using?

2.6.2

What operating system are you using?

macos 13.1 arm64

Describe the Bug

Wrangler would disconnect and need to restart manually after waking up from sleep:

./node_modules/ws/lib/sender.js:162
      throw new TypeError('First argument must be a valid error code number');
            ^
TypeError: First argument must be a valid error code number
    at Sender.close (./node_modules/ws/lib/sender.js:162:13)
    at WebSocket.close (./node_modules/ws/lib/websocket.js:300:18)
    at ./node_modules/@miniflare/web-sockets/src/couple.ts:61:10
    at ./node_modules/@miniflare/shared/src/event.ts:29:9
    at ./node_modules/@miniflare/web-sockets/src/websocket.ts:114:38
    at AsyncLocalStorage.run (node:async_hooks:330:14)
    at RequestContext.runWith (./node_modules/@miniflare/shared/src/context.ts:134:34)
    at _WebSocket.<anonymous> (./node_modules/@miniflare/web-sockets/src/websocket.ts:114:24)
    at _WebSocket.[nodejs.internal.kHybridDispatch] (node:internal/event_target:731:20)
    at _WebSocket.dispatchEvent (node:internal/event_target:673:26)
Waiting for the debugger to disconnect...
@yw662 yw662 added the bug Something that isn't working label Jan 1, 2023
@github-project-automation github-project-automation bot moved this to Untriaged in workers-sdk Jan 1, 2023
@yw662
Copy link
Author

yw662 commented Jan 1, 2023

This seems to be related to #1749

@yw662
Copy link
Author

yw662 commented Jan 1, 2023

https://github.com/cloudflare/miniflare/blob/80046ce36c1637668d99d0679ca3f0a2a4beb0c7/packages/web-sockets/src/couple.ts#L61

So it basically sended a wrong number (or sth other than number) to ws and:

    if (code === undefined) {
      buf = EMPTY_BUFFER;
    } else if (typeof code !== 'number' || !isValidStatusCode(code)) {
      throw new TypeError('First argument must be a valid error code number');

and

function isValidStatusCode(code) {
  return (
    (code >= 1000 &&
      code <= 1014 &&
      code !== 1004 &&
      code !== 1005 &&
      code !== 1006) ||
    (code >= 3000 && code <= 4999)
  );
}

could it be 1004 or 1006 or sth I guess.

@mrbbot
Copy link
Contributor

mrbbot commented Mar 20, 2023

Hey! 👋 I think this should've been fixed with cloudflare/miniflare#495, so I'm going to close this out. Feel free to reopen if this is still a problem using the latest version of Wrangler. 👍

@mrbbot mrbbot closed this as completed Mar 20, 2023
@github-project-automation github-project-automation bot moved this from Backlog to Done in workers-sdk Mar 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that isn't working
Projects
None yet
Development

No branches or pull requests

2 participants