Skip to content

fix(client): ignore forward console send failures (fix #22407)#22409

Closed
cyphercodes wants to merge 1 commit into
vitejs:mainfrom
cyphercodes:fix-forward-console-send-rejections
Closed

fix(client): ignore forward console send failures (fix #22407)#22409
cyphercodes wants to merge 1 commit into
vitejs:mainfrom
cyphercodes:fix-forward-console-send-rejections

Conversation

@cyphercodes
Copy link
Copy Markdown
Contributor

Description

Fixes #22407.

When forward console reports logs or unhandled errors after the client transport disconnects, transport.send() rejects. If that rejection is left unhandled, the forward console unhandledrejection listener can try to forward the send failure too and enter a loop.

This change routes forwarded console payloads through a shared helper that catches send failures and drops them when the transport is no longer available.

Tests

  • pnpm --filter vite build-bundle
  • pnpm run test-unit packages/vite/src/shared/__tests__/forwardConsole.spec.ts
  • pnpm exec eslint packages/vite/src/shared/forwardConsole.ts packages/vite/src/shared/__tests__/forwardConsole.spec.ts --concurrency auto
  • pnpm --filter vite build-types
  • pnpm --filter vite typecheck
  • git diff --check

@sapphi-red
Copy link
Copy Markdown
Member

Thanks, but I created a separate PR (#22450) as I thought we should log the unexpected errors and also the tests added here can be flaky.

@sapphi-red sapphi-red closed this May 14, 2026
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.

Forward console plugin enters an infinite loop

2 participants