WebSocket: Network error cause missing
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 879
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 68
Description
Bug Description
Regression of #4273. The test https://github.com/nodejs/undici/blob/4f4bf4f1a6e985e7144be5b142c84e9a4823e3de/test/websocket/issue-4273.js#L13 passes, but there is no cause with ECONNREFUSED on the error.
Reproducible By
import { WebSocket } from 'undici';
// No actual server here
const ws = new WebSocket('ws://localhost:1234');
ws.addEventListener('error', (event) => {
console.log('TypeError', event.error instanceof TypeError);
console.log('error.cause', event.error?.cause);
});
Expected Behavior
Error should have a cause with the network error.
Logs & Screenshots
N/A
Environment
macOS Tahoe 26.4. Node.js 22.22.1. Undici 8.0.2.
Additional context
N/A
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running test/websocket/issue-4273.js at the referenced revision and compare its passing behavior with the provided WebSocket reproduction. Trace the error handling involved in the connection refusal; done means the emitted error remains a TypeError and its cause contains the ECONNREFUSED network error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100