denoland / deploy_feedback

For reporting issues with Deno Deploy
https://deno.com/deploy
74 stars 5 forks source link

[Bug]: The deployment failed: failed to receive BroadcastChannel message #663

Closed danopia closed 5 months ago

danopia commented 6 months ago

Problem description

One of my existing Subhosting projects recently can't be deployed anymore, because the new deployments fail with this error:

The deployment failed: UNCAUGHT_EXCEPTION

TypeError: failed to receive BroadcastChannel message
    at async recv (ext:deno_broadcast_channel/01_broadcast_channel.js:41:21)

This error only seems to crash my deployment when the module uses await fetch() at the top level, e.g. blocking the isolate startup.

The last green deployment was from 4 days ago and still served traffic without error. It's seemingly just the deploy verification step that has begun failing.

Steps to reproduce

The error message can be reproduced in a Playground like so:

new BroadcastChannel('hello');
await fetch(`https://da.gd/ip`).then(x => x.text());
Deno.serve((req: Request) => new Response("Hello World!"));

Note that the playground still deploys ok, but the us-east-1 isolate never started listening:

gcp-us-east4  isolate start time: 17.85 ms (user time: 7.26 ms)
gcp-us-east4  TypeError: failed to receive BroadcastChannel message
    at async recv (ext:deno_broadcast_channel/01_broadcast_channel.js:41:21)
gcp-europe-west3  Listening on https://127.0.0.1:80/
gcp-europe-west3  isolate start time: 769.32 ms (user time: 642.64 ms)

If you remove the fetch() like so:

new BroadcastChannel('hello');
Deno.serve((req: Request) => new Response("Hello World!"));

Now the verification isolate in us-east4 successfully listens, despite the error still being logged:

gcp-us-east4  Listening on https://127.0.0.1:80/
gcp-us-east4  isolate start time: 16.57 ms (user time: 6.90 ms)
gcp-us-east4  TypeError: failed to receive BroadcastChannel message
    at async recv (ext:deno_broadcast_channel/01_broadcast_channel.js:41:21)
gcp-europe-west3  Listening on https://127.0.0.1:80/
gcp-europe-west3  isolate start time: 89.07 ms (user time: 6.50 ms)

I'm not sure why the deployment only fully fails with Deploy Subhosting (vs Deploy Playground).

Expected behavior

There shouldn't be an error related to the BroadcastChannel, and the deployment should succeed.

Environment

Deno Deploy, via subhosting API

Possible solution

The workarounds I've found are to either:

  1. Not use BroadcastChannel
  2. Not use await fetch() at the top level of my program

Additional context

No response

piscisaureus commented 6 months ago

Thank you for the report. We have identified the cause of this issue and are working on a fix.

danopia commented 5 months ago

Hmm, I think this works nowadays. It seems ok in the playground and my real application. Thanks