Skip to content

Update websocket-tunnel example to use quick tunnels#700

Open
aron-cf wants to merge 1 commit into
mainfrom
example-tunnel
Open

Update websocket-tunnel example to use quick tunnels#700
aron-cf wants to merge 1 commit into
mainfrom
example-tunnel

Conversation

@aron-cf
Copy link
Copy Markdown
Contributor

@aron-cf aron-cf commented May 18, 2026

This currently depends on a fix to ensure that sandbox.getProcess() returns null when using the RPC transport. Currently it incorrectly throws.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 18, 2026

⚠️ No Changeset found

Latest commit: 96ca0c8

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

View 3 additional findings in Devin Review.

Open in Devin Review

Comment on lines +25 to 31
const tunnel = await sandbox.tunnels.get(WS_PORT);
if (!tunnel) {
return new Response(
'Unable to create Cloudflare Tunnel. Note, if you are running Cloudflare WARP you will need to disable WARP to access the tunnel in local development.',
{ status: 500 }
);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Friendly tunnel error message is unreachable dead code because tunnels.get() throws instead of returning null

The TunnelsHandler.get() method (packages/sandbox/src/tunnels/tunnels-handler.ts:137) is typed as Promise<TunnelInfo> (not nullable) and its implementation always either returns a valid TunnelInfo or throws an error. Therefore the if (!tunnel) guard at examples/websocket-tunnel/src/index.ts:26 is dead code — if tunnel creation fails (e.g. due to WARP interference), the thrown error propagates as an unhandled exception and the user sees a generic 500, never the helpful WARP diagnostic message. The code should use a try/catch around sandbox.tunnels.get(WS_PORT) instead of a nullish check.

Suggested change
const tunnel = await sandbox.tunnels.get(WS_PORT);
if (!tunnel) {
return new Response(
'Unable to create Cloudflare Tunnel. Note, if you are running Cloudflare WARP you will need to disable WARP to access the tunnel in local development.',
{ status: 500 }
);
}
let tunnel: Awaited<ReturnType<typeof sandbox.tunnels.get>>;
try {
tunnel = await sandbox.tunnels.get(WS_PORT);
} catch {
return new Response(
'Unable to create Cloudflare Tunnel. Note, if you are running Cloudflare WARP you will need to disable WARP to access the tunnel in local development.',
{ status: 500 }
);
}
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, this is a good point

"vars": {
"SANDBOX_TRANSPORT": "rpc"
},
"compatibility_date": "2026-04-22",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrangler.jsonc uses 2026-04-22, but our types header says 2026-10-06? is that right? also did we go bcak to prev compat date?

i think we just need a fresh wrangler types, unless this is intentional

@whoiskatrin whoiskatrin self-requested a review May 18, 2026 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants