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

fix: ensure tail exits when the WebSocket disconnects #5275

Merged
merged 2 commits into from
Mar 18, 2024

Conversation

petebacondarwin
Copy link
Contributor

What this PR solves

Previously when the we tail WebSocket disconnected, e.g. because of an Internet failure,
the wrangler tail command would just hang and neither exit nor any longer receive tail messages.

Now the process exits with an exit code of 1, and outputs an error message.

The error message is formatted appropriately, if the tail format is set to json.

Fixes #3927

How to test

Automated tests have been added.

But you can test this manually by building Wrangler locally, tailing any Worker and then manually turning off the Internet connection. After 2 secs Wrangler should exit with a suitable error message.

Author has addressed the following

@petebacondarwin petebacondarwin requested a review from a team as a code owner March 18, 2024 10:56
Copy link

changeset-bot bot commented Mar 18, 2024

🦋 Changeset detected

Latest commit: d20e096

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
wrangler Patch
@cloudflare/vitest-pool-workers Patch

Not sure what this means? Click here to learn what changesets are.

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

Copy link
Contributor

github-actions bot commented Mar 18, 2024

A wrangler prerelease is available for testing. You can install this latest build in your project with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8330703210/npm-package-wrangler-5275

You can reference the automatically updated head of this PR with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/5275/npm-package-wrangler-5275

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8330703210/npm-package-wrangler-5275 dev path/to/script.js
Additional artifacts:
npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8330703210/npm-package-create-cloudflare-5275 --no-auto-update
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8330703210/npm-package-cloudflare-kv-asset-handler-5275
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8330703210/npm-package-miniflare-5275
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8330703210/npm-package-cloudflare-pages-shared-5275
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8330703210/npm-package-cloudflare-vitest-pool-workers-5275

Note that these links will no longer work once the GitHub Actions artifact expires.


wrangler@3.34.2 includes the following runtime dependencies:

Package Constraint Resolved
miniflare workspace:* 3.20240304.2
workerd 1.20240304.0 1.20240304.0
workerd --version 1.20240304.0 2024-03-04

Please ensure constraints are pinned, and miniflare/workerd minor versions match.

Copy link

codecov bot commented Mar 18, 2024

Codecov Report

Attention: Patch coverage is 87.09677% with 4 lines in your changes are missing coverage. Please review.

Project coverage is 71.56%. Comparing base (d4c23d2) to head (d20e096).
Report is 2 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #5275      +/-   ##
==========================================
+ Coverage   71.46%   71.56%   +0.09%     
==========================================
  Files         309      311       +2     
  Lines       16098    16195      +97     
  Branches     4111     4143      +32     
==========================================
+ Hits        11505    11590      +85     
- Misses       4593     4605      +12     
Files Coverage Δ
packages/wrangler/src/errors.ts 100.00% <100.00%> (ø)
.../wrangler/src/__tests__/helpers/mock-web-socket.ts 82.60% <60.00%> (-6.29%) ⬇️
packages/wrangler/src/tail/index.ts 93.18% <90.00%> (+2.64%) ⬆️

... and 10 files with indirect coverage changes

Previously when the we tail WebSocket disconnected, e.g. because of an Internet failure,
the `wrangler tail` command would just hang and neither exit nor any longer receive tail messages.

Now the process exits with an exit code of 1, and outputs an error message.

The error message is formatted appropriately, if the tail format is set to `json`.

Fixes #3927
@petebacondarwin petebacondarwin force-pushed the tail-disconnects branch 2 times, most recently from 49741fe to c3cb875 Compare March 18, 2024 15:45
@petebacondarwin petebacondarwin merged commit e1f2576 into main Mar 18, 2024
15 checks passed
@petebacondarwin petebacondarwin deleted the tail-disconnects branch March 18, 2024 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

🐛 BUG: wrangler tail does not recover or exit when websocket disconnects
3 participants