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

flash: passing invalid as a response results in non-catchable errors and hangs #15504

Closed
Tracked by #17146
kitsonk opened this issue Aug 20, 2022 · 1 comment · Fixed by #18568
Closed
Tracked by #17146

flash: passing invalid as a response results in non-catchable errors and hangs #15504

kitsonk opened this issue Aug 20, 2022 · 1 comment · Fixed by #18568
Assignees
Labels
bug Something isn't working correctly

Comments

@kitsonk
Copy link
Contributor

kitsonk commented Aug 20, 2022

Something like the following:

Deno.serve(() => Promise.resolve(null), {
  onError(err) {
    console.log(err);
    return new Response("error", { status: 500 });
  }
});

Will result in:

TypeError: Cannot read properties of null (reading 'Symbol([[associated_ws]])')
    at Object.serve (deno:ext/flash/01_http.js:294:28)

And the onError() method won't be called, as expected.

I have a test in oak checking that bad responses are handled gracefully.

@kitsonk kitsonk added bug Something isn't working correctly flash labels Aug 20, 2022
@brenelz
Copy link
Contributor

brenelz commented Sep 15, 2022

I think this may be as simple as changing this:

// ext/flash/01_http.js
try {
  resp = await handler(req);
} catch (e) {
  resp = await onError(e);
}

to this:

// ext/flash/01_http.js
try {
  resp = await handler(req);
  if(!resp) {
    throw new Error('Invalid response');
  }
} catch (e) {
  resp = await onError(e);
}

bartlomieju added a commit that referenced this issue Apr 3, 2023
This commit changes implementation of "Deno.serve()" API to use
"Deno.serveHttp()" under the hood. This change will allow us to
remove the "flash" server implementation, bringing stability to the
"Deno.serve()" API.

"cli/tests/unit/flash_test.ts" was renamed to "serve_test.ts".

Closes #15574
Closes #15504
Closes #15646
Closes #15909
Closes #15911
Closes #16828
Closes #18046
Closes #15869
levex pushed a commit that referenced this issue Apr 12, 2023
This commit changes implementation of "Deno.serve()" API to use
"Deno.serveHttp()" under the hood. This change will allow us to
remove the "flash" server implementation, bringing stability to the
"Deno.serve()" API.

"cli/tests/unit/flash_test.ts" was renamed to "serve_test.ts".

Closes #15574
Closes #15504
Closes #15646
Closes #15909
Closes #15911
Closes #16828
Closes #18046
Closes #15869
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants