Skip to content

Commit b5499e0

Browse files
authored
fix: emit error on non-200 proxy response in HttpUriPlugin and update AGENTS.md (#20646)
1 parent 099f72a commit b5499e0

3 files changed

Lines changed: 43 additions & 22 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"webpack": patch
3+
---
4+
5+
Emit error when proxy server returns non-200 status code in HttpUriPlugin instead of silently failing.

AGENTS.md

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,40 +9,32 @@ webpack is a JavaScript module bundler.
99
## Key Directories
1010

1111
- `lib/` — Main source code
12-
- `lib/optimize/` — Optimization plugins (tree shaking, chunk splitting, etc.)
13-
- `lib/serialization/` — Cache serialization
14-
- `lib/schemes/` — URI scheme plugins (HttpUri, DataUri, Virtual)
12+
- `lib/javascript/` — JavaScript modules parsing and generation
13+
- `lib/css/` — CSS modules parsing and generation
1514
- `schemas/` — JSON schemas for webpack options
1615
- `types.d.ts` — Auto-generated type definitions (do not edit manually)
17-
- `tooling/` — Build tooling scripts
1816
- `test/` — All tests
17+
- `examples/` — Usage examples for webpack features and configuration options
1918
- `.changeset/` — Changeset files for releases
2019

2120
All available commands are defined in `package.json` scripts. Refer to `package.json` for the latest definitions.
2221

2322
## Development Workflow
2423

25-
### 1. Making Changes to `lib/`
24+
### 1. Modifying Schemas or Types (if needed)
2625

27-
After modifying source code in `lib/`:
26+
If your change involves modifying or adding webpack configuration options:
2827

29-
```bash
30-
yarn fix:code # ESLint autofix
31-
yarn fmt # Prettier format
32-
# Or combined:
33-
yarn fix # runs fix:code + fix:special + fmt
34-
```
35-
36-
### 2. Modifying Schemas or Types
37-
38-
If your change affects module exports, options, or type definitions:
39-
40-
1. Edit the relevant schema file in `schemas/` (e.g., `schemas/WebpackOptions.json`, `schemas/plugins/`)
28+
1. Edit `schemas/WebpackOptions.json` (or relevant schema file in `schemas/plugins/`)
4129
2. Run `yarn fix:special` to regenerate:
4230
- `types.d.ts` (compiled from JSDoc + schemas)
4331
- Precompiled schema validators
4432
- Runtime code
45-
3. Other files can then reference the updated types via JSDoc `@typedef {import("...")}` imports
33+
3. Now `lib/` code can reference the updated types via JSDoc `@typedef {import("...")}` imports
34+
35+
### 2. Making Changes to `lib/`
36+
37+
Modify source code in `lib/` as needed. If step 1 was performed, the latest type definitions are already available.
4638

4739
### 3. Adding a Changeset
4840

@@ -59,7 +51,18 @@ Description of the change.
5951

6052
Use `patch` for bug fixes, `minor` for new features, `major` for breaking changes.
6153

62-
### 4. Writing Tests
54+
### 4. Linting and Formatting
55+
56+
Run linting and formatting **after** adding the changeset:
57+
58+
```bash
59+
yarn fix:code # ESLint autofix
60+
yarn fmt # Prettier format
61+
```
62+
63+
If any `lib/` file's exports (public API) were modified, also run `yarn fix:special` to regenerate types and validators. Or use `yarn fix` which combines all three (`fix:code` + `fix:special` + `fmt`).
64+
65+
### 5. Writing Tests
6366

6467
Test files live in `test/` with naming conventions:
6568

@@ -78,13 +81,15 @@ Test files live in `test/` with naming conventions:
7881

7982
For unit tests, use Jest directly. Example: `test/FileSystemInfo.unittest.js` uses `memfs` for filesystem mocking.
8083

81-
### 5. Running Tests
84+
### 6. Running Tests
85+
86+
Only run tests when test files are modified or explicitly requested.
8287

8388
**Choose test command based on modified directory:**
8489

8590
| Modified directory/file | Command |
8691
| ----------------------- | ------------------------------------------------------------------------ |
87-
| `test/*.unittest.js` | `yarn test:unit` |
92+
| `test/*.unittest.js` | `yarn test:base -- --testPathPattern="<filename>"` |
8893
| `test/cases/` | `yarn test:basic` |
8994
| `test/configCases/` | `yarn test:basic -- --testPathPattern="ConfigTestCases"` |
9095
| `test/statsCases/` | `yarn test:basic -- --testPathPattern="StatsTestCases"` |
@@ -104,3 +109,7 @@ yarn test:base -- --testNamePattern="pattern" # Run specific test name
104109
```
105110

106111
Tests require `--expose-gc --max-old-space-size=4096 --experimental-vm-modules` (already configured in scripts).
112+
113+
### 7. Updating Examples (if needed)
114+
115+
If WebpackOptions were added or modified, consider adding or updating relevant examples in `examples/`. This step is typically done after running tests.

lib/schemes/HttpUriPlugin.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ const proxyFetch = (request, proxy) => (url, options, callback) => {
7575
if (res.statusCode === 200) {
7676
// connected to proxy server
7777
doRequest(socket);
78+
} else {
79+
eventEmitter.emit(
80+
"error",
81+
new Error(
82+
`Failed to connect to proxy server "${proxy}": ${res.statusCode} ${res.statusMessage}`
83+
)
84+
);
7885
}
7986
})
8087
.on("error", (err) => {

0 commit comments

Comments
 (0)