@mswjs/interceptors 0.13.5 → 0.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -26,7 +26,7 @@ export declare class NodeClientRequest extends ClientRequest {
26
26
  requestBody: Buffer[];
27
27
  constructor([url, requestOptions, callback]: NormalizedClientRequestArgs, options: NodeClientOptions);
28
28
  write(...args: ClientRequestWriteArgs): boolean;
29
- end(...args: any): Promise<void>;
29
+ end(...args: any): this;
30
30
  emit(event: string, ...data: any[]): boolean;
31
31
  private respondWith;
32
32
  /**
@@ -147,119 +147,110 @@ var NodeClientRequest = /** @class */ (function (_super) {
147
147
  return true;
148
148
  };
149
149
  NodeClientRequest.prototype.end = function () {
150
+ var _this = this;
150
151
  var args = [];
151
152
  for (var _i = 0; _i < arguments.length; _i++) {
152
153
  args[_i] = arguments[_i];
153
154
  }
154
- return __awaiter(this, void 0, void 0, function () {
155
- var _a, chunk, encoding, callback, requestBody, isomorphicRequest, _b, resolverError, mockedResponse, isomorphicResponse, _c, _d, _e, chunk_1, encoding_1, callback_1;
156
- var e_1, _f;
157
- var _this = this;
158
- return __generator(this, function (_g) {
159
- switch (_g.label) {
160
- case 0:
161
- this.log('end', args);
162
- _a = __read(normalizeClientRequestEndArgs_1.normalizeClientRequestEndArgs.apply(void 0, __spreadArray([], __read(args))), 3), chunk = _a[0], encoding = _a[1], callback = _a[2];
163
- this.log('normalized arguments:', { chunk: chunk, encoding: encoding, callback: callback });
164
- requestBody = this.getRequestBody(chunk);
165
- isomorphicRequest = this.toIsomorphicRequest(requestBody);
166
- this.observer.emit('request', isomorphicRequest);
167
- this.log('executing response resolver...');
168
- return [4 /*yield*/, until_1.until(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
169
- return [2 /*return*/, this.resolver(isomorphicRequest, this.response)];
170
- }); }); })
171
- // Halt the request whenever the resolver throws an exception.
172
- ];
173
- case 1:
174
- _b = __read.apply(void 0, [_g.sent()
175
- // Halt the request whenever the resolver throws an exception.
176
- , 2]), resolverError = _b[0], mockedResponse = _b[1];
177
- // Halt the request whenever the resolver throws an exception.
178
- if (resolverError) {
179
- this.log('encountered resolver exception, aborting request...', resolverError);
180
- this.emit('error', resolverError);
181
- this.terminate();
182
- return [2 /*return*/];
183
- }
184
- if (mockedResponse) {
185
- this.log('received mocked response:', mockedResponse);
186
- this.responseSource = 'mock';
187
- isomorphicResponse = toIsoResponse_1.toIsoResponse(mockedResponse);
188
- this.respondWith(mockedResponse);
189
- this.log(isomorphicResponse.status, isomorphicResponse.statusText, isomorphicResponse.body, '(MOCKED)');
190
- callback === null || callback === void 0 ? void 0 : callback();
191
- this.log('emitting the custom "response" event...');
192
- this.observer.emit('response', isomorphicRequest, isomorphicResponse);
193
- return [2 /*return*/];
194
- }
195
- this.log('no mocked response found!');
196
- // Set the response source to "bypass".
197
- // Any errors emitted past this point are not suppressed.
198
- this.responseSource = 'bypass';
199
- // Propagate previously captured errors.
200
- // For example, a ECONNREFUSED error when connecting to a non-existing host.
201
- if (this.capturedError) {
202
- this.emit('error', this.capturedError);
203
- return [2 /*return*/];
204
- }
205
- // Write the request body chunks in the order of ".write()" calls.
206
- // Note that no request body has been written prior to this point
207
- // in order to prevent the Socket to communicate with a potentially
208
- // existing server.
209
- this.log('writing request chunks...', this.chunks);
210
- try {
211
- for (_c = __values(this.chunks), _d = _c.next(); !_d.done; _d = _c.next()) {
212
- _e = _d.value, chunk_1 = _e.chunk, encoding_1 = _e.encoding, callback_1 = _e.callback;
213
- encoding_1
214
- ? _super.prototype.write.call(this, chunk_1, encoding_1, callback_1)
215
- : _super.prototype.write.call(this, chunk_1, callback_1);
216
- }
217
- }
218
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
219
- finally {
220
- try {
221
- if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
222
- }
223
- finally { if (e_1) throw e_1.error; }
224
- }
225
- this.once('error', function (error) {
226
- _this.log('original request error:', error);
227
- });
228
- this.once('abort', function () {
229
- _this.log('original request aborted!');
230
- });
231
- this.once('response-internal', function (response) { return __awaiter(_this, void 0, void 0, function () {
232
- var responseBody;
233
- return __generator(this, function (_a) {
234
- switch (_a.label) {
235
- case 0: return [4 /*yield*/, getIncomingMessageBody_1.getIncomingMessageBody(response)];
236
- case 1:
237
- responseBody = _a.sent();
238
- this.log(response.statusCode, response.statusMessage, responseBody);
239
- this.log('original response headers:', response.headers);
240
- this.log('emitting the custom "response" event...');
241
- this.observer.emit('response', isomorphicRequest, {
242
- status: response.statusCode || 200,
243
- statusText: response.statusMessage || 'OK',
244
- headers: lib_1.objectToHeaders(response.headers),
245
- body: responseBody,
246
- });
247
- return [2 /*return*/];
248
- }
249
- });
250
- }); });
251
- this.log('performing original request...');
252
- return [2 /*return*/, _super.prototype.end.apply(this, __spreadArray([], __read([
253
- chunk,
254
- encoding,
255
- function () {
256
- _this.log('original request end!');
257
- callback === null || callback === void 0 ? void 0 : callback();
258
- },
259
- ].filter(Boolean))))];
155
+ this.log('end', args);
156
+ var _a = __read(normalizeClientRequestEndArgs_1.normalizeClientRequestEndArgs.apply(void 0, __spreadArray([], __read(args))), 3), chunk = _a[0], encoding = _a[1], callback = _a[2];
157
+ this.log('normalized arguments:', { chunk: chunk, encoding: encoding, callback: callback });
158
+ var requestBody = this.getRequestBody(chunk);
159
+ var isomorphicRequest = this.toIsomorphicRequest(requestBody);
160
+ this.observer.emit('request', isomorphicRequest);
161
+ this.log('executing response resolver...');
162
+ // Execute the resolver Promise like a side-effect.
163
+ // Node.js 16 forces "ClientRequest.end" to be synchronous and return "this".
164
+ until_1.until(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
165
+ return [2 /*return*/, this.resolver(isomorphicRequest, this.response)];
166
+ }); }); }).then(function (_a) {
167
+ var e_1, _b;
168
+ var _c = __read(_a, 2), resolverException = _c[0], mockedResponse = _c[1];
169
+ // Halt the request whenever the resolver throws an exception.
170
+ if (resolverException) {
171
+ _this.log('encountered resolver exception, aborting request...', resolverException);
172
+ _this.emit('error', resolverException);
173
+ _this.terminate();
174
+ return _this;
175
+ }
176
+ if (mockedResponse) {
177
+ _this.log('received mocked response:', mockedResponse);
178
+ _this.responseSource = 'mock';
179
+ var isomorphicResponse = toIsoResponse_1.toIsoResponse(mockedResponse);
180
+ _this.respondWith(mockedResponse);
181
+ _this.log(isomorphicResponse.status, isomorphicResponse.statusText, isomorphicResponse.body, '(MOCKED)');
182
+ callback === null || callback === void 0 ? void 0 : callback();
183
+ _this.log('emitting the custom "response" event...');
184
+ _this.observer.emit('response', isomorphicRequest, isomorphicResponse);
185
+ return _this;
186
+ }
187
+ _this.log('no mocked response found!');
188
+ // Set the response source to "bypass".
189
+ // Any errors emitted past this point are not suppressed.
190
+ _this.responseSource = 'bypass';
191
+ // Propagate previously captured errors.
192
+ // For example, a ECONNREFUSED error when connecting to a non-existing host.
193
+ if (_this.capturedError) {
194
+ _this.emit('error', _this.capturedError);
195
+ return _this;
196
+ }
197
+ // Write the request body chunks in the order of ".write()" calls.
198
+ // Note that no request body has been written prior to this point
199
+ // in order to prevent the Socket to communicate with a potentially
200
+ // existing server.
201
+ _this.log('writing request chunks...', _this.chunks);
202
+ try {
203
+ for (var _d = __values(_this.chunks), _e = _d.next(); !_e.done; _e = _d.next()) {
204
+ var _f = _e.value, chunk_1 = _f.chunk, encoding_1 = _f.encoding, callback_1 = _f.callback;
205
+ encoding_1
206
+ ? _super.prototype.write.call(_this, chunk_1, encoding_1, callback_1)
207
+ : _super.prototype.write.call(_this, chunk_1, callback_1);
260
208
  }
209
+ }
210
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
211
+ finally {
212
+ try {
213
+ if (_e && !_e.done && (_b = _d.return)) _b.call(_d);
214
+ }
215
+ finally { if (e_1) throw e_1.error; }
216
+ }
217
+ _this.once('error', function (error) {
218
+ _this.log('original request error:', error);
261
219
  });
220
+ _this.once('abort', function () {
221
+ _this.log('original request aborted!');
222
+ });
223
+ _this.once('response-internal', function (response) { return __awaiter(_this, void 0, void 0, function () {
224
+ var responseBody;
225
+ return __generator(this, function (_a) {
226
+ switch (_a.label) {
227
+ case 0: return [4 /*yield*/, getIncomingMessageBody_1.getIncomingMessageBody(response)];
228
+ case 1:
229
+ responseBody = _a.sent();
230
+ this.log(response.statusCode, response.statusMessage, responseBody);
231
+ this.log('original response headers:', response.headers);
232
+ this.log('emitting the custom "response" event...');
233
+ this.observer.emit('response', isomorphicRequest, {
234
+ status: response.statusCode || 200,
235
+ statusText: response.statusMessage || 'OK',
236
+ headers: lib_1.objectToHeaders(response.headers),
237
+ body: responseBody,
238
+ });
239
+ return [2 /*return*/];
240
+ }
241
+ });
242
+ }); });
243
+ _this.log('performing original request...');
244
+ return _super.prototype.end.apply(_this, __spreadArray([], __read([
245
+ chunk,
246
+ encoding,
247
+ function () {
248
+ _this.log('original request end!');
249
+ callback === null || callback === void 0 ? void 0 : callback();
250
+ },
251
+ ].filter(Boolean))));
262
252
  });
253
+ return this;
263
254
  };
264
255
  NodeClientRequest.prototype.emit = function (event) {
265
256
  var data = [];
@@ -1 +1 @@
1
- {"version":3,"file":"NodeClientRequest.js","sourceRoot":"","sources":["../../../src/interceptors/ClientRequest/NodeClientRequest.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAAuC;AAEvC,6BAAqD;AACrD,2CAAyC;AACzC,4CAA+D;AAO/D,yCAAyC;AACzC,mEAAiE;AACjE,uFAG8C;AAE9C,2DAAyD;AACzD,yEAAuE;AACvE,iEAA+D;AAC/D,2FAIgD;AAChD,qEAAmE;AASnE;IAAuC,qCAAa;IAuBlD,2BACE,EAA4D,EAC5D,OAA0B;YAD1B,KAAA,aAA4D,EAA3D,GAAG,QAAA,EAAE,cAAc,QAAA,EAAE,QAAQ,QAAA;QADhC,YAIE,kBAAM,cAAc,EAAE,QAAQ,CAAC,SAgB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E,YAAY,CAAC,CAAA;IAuVzE,wBAAC;CAAA,AA5VD,CAAuC,oBAAa,GA4VnD;AA5VY,8CAAiB"}
@@ -32,7 +32,7 @@ function request(protocol, resolver, observer) {
32
32
  for (var _i = 0; _i < arguments.length; _i++) {
33
33
  args[_i] = arguments[_i];
34
34
  }
35
- log('intercepted request:', args);
35
+ log('request call (protocol "%s"):', protocol, args);
36
36
  var clientRequestArgs = normalizeClientRequestArgs_1.normalizeClientRequestArgs.apply(void 0, __spreadArray([protocol + ":"], __read(args)));
37
37
  return new NodeClientRequest_1.NodeClientRequest(clientRequestArgs, {
38
38
  observer: observer,
@@ -1 +1 @@
1
- {"version":3,"file":"http.request.js","sourceRoot":"","sources":["../../../src/interceptors/ClientRequest/http.request.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAA6B;AAG7B,yDAAiE;AACjE,iFAG2C;AAE3C,IAAM,GAAG,GAAG,aAAK,CAAC,cAAc,CAAC,CAAA;AAEjC,SAAgB,OAAO,CACrB,QAAkB,EAClB,QAAkB,EAClB,QAAkB;IAElB,OAAO;QAAC,cAA0B;aAA1B,UAA0B,EAA1B,qBAA0B,EAA1B,IAA0B;YAA1B,yBAA0B;;QAChC,GAAG,CAAC,sBAAsB,EAAE,IAAI,CAAC,CAAA;QAEjC,IAAM,iBAAiB,GAAG,uDAA0B,8BAC/C,QAAQ,MAAG,UACX,IAAI,GACR,CAAA;QACD,OAAO,IAAI,qCAAiB,CAAC,iBAAiB,EAAE;YAC9C,QAAQ,UAAA;YACR,QAAQ,UAAA;SACT,CAAC,CAAA;IACJ,CAAC,CAAA;AACH,CAAC;AAjBD,0BAiBC"}
1
+ {"version":3,"file":"http.request.js","sourceRoot":"","sources":["../../../src/interceptors/ClientRequest/http.request.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAA6B;AAG7B,yDAAiE;AACjE,iFAG2C;AAE3C,IAAM,GAAG,GAAG,aAAK,CAAC,cAAc,CAAC,CAAA;AAEjC,SAAgB,OAAO,CACrB,QAAkB,EAClB,QAAkB,EAClB,QAAkB;IAElB,OAAO;QAAC,cAA0B;aAA1B,UAA0B,EAA1B,qBAA0B,EAA1B,IAA0B;YAA1B,yBAA0B;;QAChC,GAAG,CAAC,+BAA+B,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAA;QAEpD,IAAM,iBAAiB,GAAG,uDAA0B,8BAC/C,QAAQ,MAAG,UACX,IAAI,GACR,CAAA;QACD,OAAO,IAAI,qCAAiB,CAAC,iBAAiB,EAAE;YAC9C,QAAQ,UAAA;YACR,QAAQ,UAAA;SACT,CAAC,CAAA;IACJ,CAAC,CAAA;AACH,CAAC;AAjBD,0BAiBC"}
@@ -4,4 +4,7 @@ export declare const IS_CLONE: unique symbol;
4
4
  export interface ClonedIncomingMessage extends IncomingMessage {
5
5
  [IS_CLONE]: boolean;
6
6
  }
7
+ /**
8
+ * Clones a given `http.IncomingMessage` instance.
9
+ */
7
10
  export declare function cloneIncomingMessage(message: IncomingMessage): ClonedIncomingMessage;
@@ -1,15 +1,4 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
2
  var __read = (this && this.__read) || function (o, n) {
14
3
  var m = typeof Symbol === "function" && o[Symbol.iterator];
15
4
  if (!m) return o;
@@ -44,20 +33,60 @@ var __values = (this && this.__values) || function(o) {
44
33
  };
45
34
  Object.defineProperty(exports, "__esModule", { value: true });
46
35
  exports.cloneIncomingMessage = exports.IS_CLONE = void 0;
36
+ var http_1 = require("http");
47
37
  var stream_1 = require("stream");
48
38
  exports.IS_CLONE = Symbol('isClone');
39
+ /**
40
+ * Clones a given `http.IncomingMessage` instance.
41
+ */
49
42
  function cloneIncomingMessage(message) {
43
+ var clone = message.pipe(new stream_1.PassThrough());
44
+ // Inherit all direct "IncomingMessage" properties.
45
+ inheritProperties(message, clone);
46
+ // Deeply inherit the message prototypes (Readable, Stream, EventEmitter, etc.).
47
+ var clonedPrototype = Object.create(http_1.IncomingMessage.prototype);
48
+ getPrototypes(clone).forEach(function (prototype) {
49
+ inheritProperties(prototype, clonedPrototype);
50
+ });
51
+ Object.setPrototypeOf(clone, clonedPrototype);
52
+ Object.defineProperty(clone, exports.IS_CLONE, {
53
+ enumerable: true,
54
+ value: true,
55
+ });
56
+ return clone;
57
+ }
58
+ exports.cloneIncomingMessage = cloneIncomingMessage;
59
+ /**
60
+ * Returns a list of all prototypes the given object extends.
61
+ */
62
+ function getPrototypes(source) {
63
+ var prototypes = [];
64
+ var current = source;
65
+ while ((current = Object.getPrototypeOf(current))) {
66
+ prototypes.push(current);
67
+ }
68
+ return prototypes;
69
+ }
70
+ /**
71
+ * Inherits a given target object properties and symbols
72
+ * onto the given source object.
73
+ * @param source Object which should acquire properties.
74
+ * @param target Object to inherit the properties from.
75
+ */
76
+ function inheritProperties(source, target) {
50
77
  var e_1, _a;
51
- var stream = message.pipe(new stream_1.PassThrough());
52
- var properties = __spreadArray(__spreadArray([], __read(Object.getOwnPropertyNames(message))), __read(Object.getOwnPropertySymbols(message)));
78
+ var properties = __spreadArray(__spreadArray([], __read(Object.getOwnPropertyNames(source))), __read(Object.getOwnPropertySymbols(source)));
53
79
  try {
54
80
  for (var properties_1 = __values(properties), properties_1_1 = properties_1.next(); !properties_1_1.done; properties_1_1 = properties_1.next()) {
55
- var propertyName = properties_1_1.value;
56
- if (stream.hasOwnProperty(propertyName)) {
81
+ var property = properties_1_1.value;
82
+ if (target.hasOwnProperty(property)) {
83
+ continue;
84
+ }
85
+ var descriptor = Object.getOwnPropertyDescriptor(source, property);
86
+ if (!descriptor) {
57
87
  continue;
58
88
  }
59
- var propertyDescriptor = Object.getOwnPropertyDescriptor(message, propertyName);
60
- Object.defineProperty(stream, propertyName, __assign(__assign({}, propertyDescriptor), { value: message[propertyName] }));
89
+ Object.defineProperty(target, property, descriptor);
61
90
  }
62
91
  }
63
92
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
@@ -67,11 +96,5 @@ function cloneIncomingMessage(message) {
67
96
  }
68
97
  finally { if (e_1) throw e_1.error; }
69
98
  }
70
- Object.defineProperty(stream, exports.IS_CLONE, {
71
- enumerable: true,
72
- value: true,
73
- });
74
- return stream;
75
99
  }
76
- exports.cloneIncomingMessage = cloneIncomingMessage;
77
100
  //# sourceMappingURL=cloneIncomingMessage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cloneIncomingMessage.js","sourceRoot":"","sources":["../../../../src/interceptors/ClientRequest/utils/cloneIncomingMessage.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,iCAAoC;AAEvB,QAAA,QAAQ,GAAG,MAAM,CAAC,SAAS,CAAC,CAAA;AAMzC,SAAgB,oBAAoB,CAClC,OAAwB;;IAExB,IAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,oBAAW,EAAE,CAAC,CAAA;IAC9C,IAAM,UAAU,GAAG,uCACd,MAAM,CAAC,mBAAmB,CAAC,OAAO,CAAC,WACnC,MAAM,CAAC,qBAAqB,CAAC,OAAO,CAAC,EACT,CAAA;;QAEjC,KAA2B,IAAA,eAAA,SAAA,UAAU,CAAA,sCAAA,8DAAE;YAAlC,IAAM,YAAY,uBAAA;YACrB,IAAI,MAAM,CAAC,cAAc,CAAC,YAAY,CAAC,EAAE;gBACvC,SAAQ;aACT;YAED,IAAM,kBAAkB,GAAG,MAAM,CAAC,wBAAwB,CACxD,OAAO,EACP,YAAY,CACb,CAAA;YAED,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,YAAY,wBACrC,kBAAkB,KACrB,KAAK,EAAE,OAAO,CAAC,YAAY,CAAC,IAC5B,CAAA;SACH;;;;;;;;;IAED,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,gBAAQ,EAAE;QACtC,UAAU,EAAE,IAAI;QAChB,KAAK,EAAE,IAAI;KACZ,CAAC,CAAA;IAEF,OAAO,MAA0C,CAAA;AACnD,CAAC;AA/BD,oDA+BC"}
1
+ {"version":3,"file":"cloneIncomingMessage.js","sourceRoot":"","sources":["../../../../src/interceptors/ClientRequest/utils/cloneIncomingMessage.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAAsC;AACtC,iCAAoC;AAEvB,QAAA,QAAQ,GAAG,MAAM,CAAC,SAAS,CAAC,CAAA;AAMzC;;GAEG;AACH,SAAgB,oBAAoB,CAClC,OAAwB;IAExB,IAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,oBAAW,EAAE,CAAC,CAAA;IAE7C,mDAAmD;IACnD,iBAAiB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IAEjC,gFAAgF;IAChF,IAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,sBAAe,CAAC,SAAS,CAAC,CAAA;IAChE,aAAa,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,UAAC,SAAS;QACrC,iBAAiB,CAAC,SAAS,EAAE,eAAe,CAAC,CAAA;IAC/C,CAAC,CAAC,CAAA;IACF,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,eAAe,CAAC,CAAA;IAE7C,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,gBAAQ,EAAE;QACrC,UAAU,EAAE,IAAI;QAChB,KAAK,EAAE,IAAI;KACZ,CAAC,CAAA;IAEF,OAAO,KAAyC,CAAA;AAClD,CAAC;AArBD,oDAqBC;AAED;;GAEG;AACH,SAAS,aAAa,CAAC,MAAc;IACnC,IAAM,UAAU,GAAa,EAAE,CAAA;IAC/B,IAAI,OAAO,GAAG,MAAM,CAAA;IAEpB,OAAO,CAAC,OAAO,GAAG,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,EAAE;QACjD,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;KACzB;IAED,OAAO,UAAU,CAAA;AACnB,CAAC;AAED;;;;;GAKG;AACH,SAAS,iBAAiB,CAAC,MAAc,EAAE,MAAc;;IACvD,IAAM,UAAU,0CACX,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,WAClC,MAAM,CAAC,qBAAqB,CAAC,MAAM,CAAC,EACxC,CAAA;;QAED,KAAuB,IAAA,eAAA,SAAA,UAAU,CAAA,sCAAA,8DAAE;YAA9B,IAAM,QAAQ,uBAAA;YACjB,IAAI,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE;gBACnC,SAAQ;aACT;YAED,IAAM,UAAU,GAAG,MAAM,CAAC,wBAAwB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;YACpE,IAAI,CAAC,UAAU,EAAE;gBACf,SAAQ;aACT;YAED,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAA;SACpD;;;;;;;;;AACH,CAAC"}
@@ -160,8 +160,22 @@ function normalizeClientRequestArgs(defaultProtocol) {
160
160
  options.agent = agent;
161
161
  log('resolved fallback agent:', agent);
162
162
  }
163
+ /**
164
+ * Ensure that the default Agent is always set.
165
+ * This prevents the protocol mismatch for requests with { agent: false },
166
+ * where the global Agent is inferred.
167
+ * @see https://github.com/mswjs/msw/issues/1150
168
+ * @see https://github.com/nodejs/node/blob/418ff70b810f0e7112d48baaa72932a56cfa213b/lib/_http_client.js#L130
169
+ * @see https://github.com/nodejs/node/blob/418ff70b810f0e7112d48baaa72932a56cfa213b/lib/_http_client.js#L157-L159
170
+ */
171
+ if (!options._defaultAgent) {
172
+ log('has no default agent, setting the default agent for "%s"', options.protocol);
173
+ options._defaultAgent =
174
+ options.protocol === 'https:' ? https_1.globalAgent : http_1.globalAgent;
175
+ }
163
176
  log('successfully resolved url:', url.href);
164
177
  log('successfully resolved options:', options);
178
+ log('successfully resolved callback:', callback);
165
179
  return [url, options, callback];
166
180
  }
167
181
  exports.normalizeClientRequestArgs = normalizeClientRequestArgs;
@@ -1 +1 @@
1
- {"version":3,"file":"normalizeClientRequestArgs.js","sourceRoot":"","sources":["../../../../src/interceptors/ClientRequest/utils/normalizeClientRequestArgs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAA6B;AAC7B,6BAA0D;AAC1D,+BAA2D;AAE3D,gFAA8E;AAC9E,gFAG8C;AAC9C,0DAAwD;AACxD,oDAAkD;AAElD,IAAM,GAAG,GAAG,aAAK,CAAC,iCAAiC,CAAC,CAAA;AASpD,SAAS,qBAAqB,CAC5B,IAAuB,EACvB,GAAQ;IAER,uDAAuD;IACvD,4CAA4C;IAC5C,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,WAAW,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,UAAU,EAAE;QACnE,GAAG,CAAC,qDAAqD,EAAE,GAAG,CAAC,CAAA;QAC/D,OAAO,+CAAsB,CAAC,GAAG,CAAC,CAAA;KACnC;IAED,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE;QACX,GAAG,CAAC,4BAA4B,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;QAC1C,IAAM,qBAAqB,GAAG,+CAAsB,CAAC,GAAG,CAAC,CAAA;QAEzD,GAAG,CAAC,sCAAsC,EAAE,qBAAqB,CAAC,CAAA;QAElE;;;;WAIG;QACH,GAAG,CAAC,2BAA2B,CAAC,CAAA;QAChC,IAAM,oBAAoB,GAAG,yBAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;QACjD,GAAG,CAAC,qCAAqC,EAAE,oBAAoB,CAAC,CAAA;QAEhE,6BACK,qBAAqB,GACrB,oBAAoB,EACxB;KACF;IAED,GAAG,CAAC,0CAA0C,CAAC,CAAA;IAC/C,OAAO,EAAoB,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AK,CAAC,CAAA;KACvC;IAED,GAAG,CAAC,4BAA4B,EAAE,GAAG,CAAC,IAAI,CAAC,CAAA;IAC3C,GAAG,CAAC,gCAAgC,EAAE,OAAO,CAAC,CAAA;IAE9C,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAA;AACjC,CAAC;AAnID,gEAmIC"}
1
+ {"version":3,"file":"normalizeClientRequestArgs.js","sourceRoot":"","sources":["../../../../src/interceptors/ClientRequest/utils/normalizeClientRequestArgs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAA6B;AAC7B,6BAIa;AACb,+BAIc;AAEd,gFAA8E;AAC9E,gFAG8C;AAC9C,0DAAwD;AACxD,oDAAkD;AAElD,IAAM,GAAG,GAAG,aAAK,CAAC,iCAAiC,CAAC,CAAA;AASpD,SAAS,qBAAqB,CAC5B,IAAuB,EACvB,GAAQ;IAER,uDAAuD;IACvD,4CAA4C;IAC5C,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,WAAW,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,UAAU,EAAE;QACnE,GAAG,CAAC,qDAAqD,EAAE,GAAG,CAAC,CAAA;QAC/D,OAAO,+CAAsB,CAAC,GAAG,CAAC,CAAA;KACnC;IAED,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE;QACX,GAAG,CAAC,4BAA4B,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;QAC1C,IAAM,qBAAqB,GAAG,+CAAsB,CAAC,GAAG,CAAC,CAAA;QAEzD,GAAG,CAAC,sCAAsC,EAAE,qBAAqB,CAAC,CAAA;QAElE;;;;WAIG;QACH,GAAG,CAAC,2BAA2B,CAAC,CAAA;QAChC,IAAM,oBAAoB,GAAG,yBAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;QACjD,GAAG,CAAC,qCAAqC,EAAE,oBAAoB,CAAC,CAAA;QAEhE,6BACK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,CAAA;IAE5C,OAAO;QACL,EAAE,YAAC,KAAK,EAAE,QAAQ;YAChB,QAAQ,CAAC,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;QACvC,CAAC;KACF,CAAA;AACH,CAAC;AA/DD,oDA+DC"}
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@mswjs/interceptors",
3
3
  "description": "Low-level HTTP/HTTPS/XHR/fetch request interception library.",
4
- "version": "0.13.5",
4
+ "version": "0.14.1",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "author": "Artem Zakharchenko",
8
8
  "license": "MIT",
9
9
  "engines": {
10
- "node": ">=12.x"
10
+ "node": ">=16.x"
11
11
  },
12
12
  "scripts": {
13
13
  "start": "tsc --build -w",
@@ -19,7 +19,8 @@
19
19
  "clean": "rimraf lib",
20
20
  "build": "yarn clean && tsc --build",
21
21
  "prepare": "yarn simple-git-hooks init",
22
- "prepublishOnly": "yarn build"
22
+ "release": "semantic-release",
23
+ "prepublishOnly": "yarn build && yarn test"
23
24
  },
24
25
  "files": [
25
26
  "lib",
@@ -36,9 +37,9 @@
36
37
  "@open-draft/test-server": "^0.2.3",
37
38
  "@types/cors": "^2.8.12",
38
39
  "@types/express": "^4.17.13",
39
- "@types/express-rate-limit": "^5.1.3",
40
+ "@types/express-rate-limit": "^6.0.0",
40
41
  "@types/jest": "^27.0.3",
41
- "@types/node": "^14.14.35",
42
+ "@types/node": "^16.11.26",
42
43
  "@types/node-fetch": "2.5.12",
43
44
  "@types/supertest": "^2.0.11",
44
45
  "@types/xmldom": "^0.1.31",
@@ -47,13 +48,14 @@
47
48
  "commitizen": "^4.2.4",
48
49
  "cors": "^2.8.5",
49
50
  "cz-conventional-changelog": "3.3.0",
50
- "express": "^4.17.1",
51
- "express-rate-limit": "^5.5.1",
51
+ "express": "^4.17.3",
52
+ "express-rate-limit": "^6.3.0",
52
53
  "got": "^11.8.3",
53
54
  "jest": "^27.4.3",
54
55
  "node-fetch": "2.6.7",
55
56
  "page-with": "^0.5.1",
56
57
  "rimraf": "^3.0.2",
58
+ "semantic-release": "^19.0.2",
57
59
  "simple-git-hooks": "^2.7.0",
58
60
  "superagent": "^6.1.0",
59
61
  "supertest": "^6.1.6",
@@ -105,7 +105,7 @@ export class NodeClientRequest extends ClientRequest {
105
105
  return true
106
106
  }
107
107
 
108
- async end(...args: any): Promise<void> {
108
+ end(...args: any): this {
109
109
  this.log('end', args)
110
110
 
111
111
  const [chunk, encoding, callback] = normalizeClientRequestEndArgs(...args)
@@ -116,101 +116,106 @@ export class NodeClientRequest extends ClientRequest {
116
116
  this.observer.emit('request', isomorphicRequest)
117
117
 
118
118
  this.log('executing response resolver...')
119
- const [resolverError, mockedResponse] = await until(async () =>
120
- this.resolver(isomorphicRequest, this.response)
121
- )
122
-
123
- // Halt the request whenever the resolver throws an exception.
124
- if (resolverError) {
125
- this.log(
126
- 'encountered resolver exception, aborting request...',
127
- resolverError
128
- )
129
- this.emit('error', resolverError)
130
- this.terminate()
131
-
132
- return
133
- }
134
-
135
- if (mockedResponse) {
136
- this.log('received mocked response:', mockedResponse)
137
- this.responseSource = 'mock'
138
-
139
- const isomorphicResponse = toIsoResponse(mockedResponse)
140
- this.respondWith(mockedResponse)
141
- this.log(
142
- isomorphicResponse.status,
143
- isomorphicResponse.statusText,
144
- isomorphicResponse.body,
145
- '(MOCKED)'
146
- )
147
119
 
148
- callback?.()
149
-
150
- this.log('emitting the custom "response" event...')
151
- this.observer.emit('response', isomorphicRequest, isomorphicResponse)
120
+ // Execute the resolver Promise like a side-effect.
121
+ // Node.js 16 forces "ClientRequest.end" to be synchronous and return "this".
122
+ until(async () => this.resolver(isomorphicRequest, this.response)).then(
123
+ ([resolverException, mockedResponse]) => {
124
+ // Halt the request whenever the resolver throws an exception.
125
+ if (resolverException) {
126
+ this.log(
127
+ 'encountered resolver exception, aborting request...',
128
+ resolverException
129
+ )
130
+ this.emit('error', resolverException)
131
+ this.terminate()
132
+
133
+ return this
134
+ }
152
135
 
153
- return
154
- }
136
+ if (mockedResponse) {
137
+ this.log('received mocked response:', mockedResponse)
138
+ this.responseSource = 'mock'
155
139
 
156
- this.log('no mocked response found!')
140
+ const isomorphicResponse = toIsoResponse(mockedResponse)
141
+ this.respondWith(mockedResponse)
142
+ this.log(
143
+ isomorphicResponse.status,
144
+ isomorphicResponse.statusText,
145
+ isomorphicResponse.body,
146
+ '(MOCKED)'
147
+ )
157
148
 
158
- // Set the response source to "bypass".
159
- // Any errors emitted past this point are not suppressed.
160
- this.responseSource = 'bypass'
149
+ callback?.()
161
150
 
162
- // Propagate previously captured errors.
163
- // For example, a ECONNREFUSED error when connecting to a non-existing host.
164
- if (this.capturedError) {
165
- this.emit('error', this.capturedError)
166
- return
167
- }
151
+ this.log('emitting the custom "response" event...')
152
+ this.observer.emit('response', isomorphicRequest, isomorphicResponse)
168
153
 
169
- // Write the request body chunks in the order of ".write()" calls.
170
- // Note that no request body has been written prior to this point
171
- // in order to prevent the Socket to communicate with a potentially
172
- // existing server.
173
- this.log('writing request chunks...', this.chunks)
174
- for (const { chunk, encoding, callback } of this.chunks) {
175
- encoding
176
- ? super.write(chunk, encoding, callback)
177
- : super.write(chunk, callback)
178
- }
154
+ return this
155
+ }
179
156
 
180
- this.once('error', (error) => {
181
- this.log('original request error:', error)
182
- })
157
+ this.log('no mocked response found!')
183
158
 
184
- this.once('abort', () => {
185
- this.log('original request aborted!')
186
- })
159
+ // Set the response source to "bypass".
160
+ // Any errors emitted past this point are not suppressed.
161
+ this.responseSource = 'bypass'
187
162
 
188
- this.once('response-internal', async (response: IncomingMessage) => {
189
- const responseBody = await getIncomingMessageBody(response)
190
- this.log(response.statusCode, response.statusMessage, responseBody)
191
- this.log('original response headers:', response.headers)
192
-
193
- this.log('emitting the custom "response" event...')
194
- this.observer.emit('response', isomorphicRequest, {
195
- status: response.statusCode || 200,
196
- statusText: response.statusMessage || 'OK',
197
- headers: objectToHeaders(response.headers),
198
- body: responseBody,
199
- })
200
- })
163
+ // Propagate previously captured errors.
164
+ // For example, a ECONNREFUSED error when connecting to a non-existing host.
165
+ if (this.capturedError) {
166
+ this.emit('error', this.capturedError)
167
+ return this
168
+ }
201
169
 
202
- this.log('performing original request...')
170
+ // Write the request body chunks in the order of ".write()" calls.
171
+ // Note that no request body has been written prior to this point
172
+ // in order to prevent the Socket to communicate with a potentially
173
+ // existing server.
174
+ this.log('writing request chunks...', this.chunks)
175
+ for (const { chunk, encoding, callback } of this.chunks) {
176
+ encoding
177
+ ? super.write(chunk, encoding, callback)
178
+ : super.write(chunk, callback)
179
+ }
203
180
 
204
- return super.end(
205
- ...[
206
- chunk,
207
- encoding as any,
208
- () => {
209
- this.log('original request end!')
210
- callback?.()
211
- },
212
- ].filter(Boolean)
181
+ this.once('error', (error) => {
182
+ this.log('original request error:', error)
183
+ })
184
+
185
+ this.once('abort', () => {
186
+ this.log('original request aborted!')
187
+ })
188
+
189
+ this.once('response-internal', async (response: IncomingMessage) => {
190
+ const responseBody = await getIncomingMessageBody(response)
191
+ this.log(response.statusCode, response.statusMessage, responseBody)
192
+ this.log('original response headers:', response.headers)
193
+
194
+ this.log('emitting the custom "response" event...')
195
+ this.observer.emit('response', isomorphicRequest, {
196
+ status: response.statusCode || 200,
197
+ statusText: response.statusMessage || 'OK',
198
+ headers: objectToHeaders(response.headers),
199
+ body: responseBody,
200
+ })
201
+ })
202
+
203
+ this.log('performing original request...')
204
+
205
+ return super.end(
206
+ ...[
207
+ chunk,
208
+ encoding as any,
209
+ () => {
210
+ this.log('original request end!')
211
+ callback?.()
212
+ },
213
+ ].filter(Boolean)
214
+ )
215
+ }
213
216
  )
217
+
218
+ return this
214
219
  }
215
220
 
216
221
  emit(event: string, ...data: any[]) {
@@ -15,7 +15,7 @@ export function request(
15
15
  observer: Observer
16
16
  ) {
17
17
  return (...args: ClientRequestArgs): ClientRequest => {
18
- log('intercepted request:', args)
18
+ log('request call (protocol "%s"):', protocol, args)
19
19
 
20
20
  const clientRequestArgs = normalizeClientRequestArgs(
21
21
  `${protocol}:`,
@@ -1,13 +1,20 @@
1
1
  import { Socket } from 'net'
2
2
  import { IncomingMessage } from 'http'
3
+ import { Stream, Readable, EventEmitter } from 'stream'
3
4
  import { cloneIncomingMessage, IS_CLONE } from './cloneIncomingMessage'
4
5
 
5
6
  test('clones a given IncomingMessage', () => {
6
- const source = new IncomingMessage(new Socket())
7
- source.statusCode = 200
8
- source.statusMessage = 'OK'
9
- source.headers = { 'x-powered-by': 'msw' }
10
- const clone = cloneIncomingMessage(source)
7
+ const message = new IncomingMessage(new Socket())
8
+ message.statusCode = 200
9
+ message.statusMessage = 'OK'
10
+ message.headers = { 'x-powered-by': 'msw' }
11
+ const clone = cloneIncomingMessage(message)
12
+
13
+ // Prototypes must be preserved.
14
+ expect(clone).toBeInstanceOf(IncomingMessage)
15
+ expect(clone).toBeInstanceOf(EventEmitter)
16
+ expect(clone).toBeInstanceOf(Stream)
17
+ expect(clone).toBeInstanceOf(Readable)
11
18
 
12
19
  expect(clone.statusCode).toEqual(200)
13
20
  expect(clone.statusMessage).toEqual('OK')
@@ -15,6 +22,4 @@ test('clones a given IncomingMessage', () => {
15
22
 
16
23
  // Cloned IncomingMessage must be marked respectively.
17
24
  expect(clone[IS_CLONE]).toEqual(true)
18
-
19
- expect(clone).toHaveProperty('_events')
20
25
  })
@@ -7,35 +7,68 @@ export interface ClonedIncomingMessage extends IncomingMessage {
7
7
  [IS_CLONE]: boolean
8
8
  }
9
9
 
10
+ /**
11
+ * Clones a given `http.IncomingMessage` instance.
12
+ */
10
13
  export function cloneIncomingMessage(
11
14
  message: IncomingMessage
12
15
  ): ClonedIncomingMessage {
13
- const stream = message.pipe(new PassThrough())
14
- const properties = [
15
- ...Object.getOwnPropertyNames(message),
16
- ...Object.getOwnPropertySymbols(message),
17
- ] as Array<keyof IncomingMessage>
18
-
19
- for (const propertyName of properties) {
20
- if (stream.hasOwnProperty(propertyName)) {
21
- continue
22
- }
16
+ const clone = message.pipe(new PassThrough())
23
17
 
24
- const propertyDescriptor = Object.getOwnPropertyDescriptor(
25
- message,
26
- propertyName
27
- )
18
+ // Inherit all direct "IncomingMessage" properties.
19
+ inheritProperties(message, clone)
28
20
 
29
- Object.defineProperty(stream, propertyName, {
30
- ...propertyDescriptor,
31
- value: message[propertyName],
32
- })
33
- }
21
+ // Deeply inherit the message prototypes (Readable, Stream, EventEmitter, etc.).
22
+ const clonedPrototype = Object.create(IncomingMessage.prototype)
23
+ getPrototypes(clone).forEach((prototype) => {
24
+ inheritProperties(prototype, clonedPrototype)
25
+ })
26
+ Object.setPrototypeOf(clone, clonedPrototype)
34
27
 
35
- Object.defineProperty(stream, IS_CLONE, {
28
+ Object.defineProperty(clone, IS_CLONE, {
36
29
  enumerable: true,
37
30
  value: true,
38
31
  })
39
32
 
40
- return stream as unknown as ClonedIncomingMessage
33
+ return clone as unknown as ClonedIncomingMessage
34
+ }
35
+
36
+ /**
37
+ * Returns a list of all prototypes the given object extends.
38
+ */
39
+ function getPrototypes(source: object): object[] {
40
+ const prototypes: object[] = []
41
+ let current = source
42
+
43
+ while ((current = Object.getPrototypeOf(current))) {
44
+ prototypes.push(current)
45
+ }
46
+
47
+ return prototypes
48
+ }
49
+
50
+ /**
51
+ * Inherits a given target object properties and symbols
52
+ * onto the given source object.
53
+ * @param source Object which should acquire properties.
54
+ * @param target Object to inherit the properties from.
55
+ */
56
+ function inheritProperties(source: object, target: object): void {
57
+ const properties = [
58
+ ...Object.getOwnPropertyNames(source),
59
+ ...Object.getOwnPropertySymbols(source),
60
+ ]
61
+
62
+ for (const property of properties) {
63
+ if (target.hasOwnProperty(property)) {
64
+ continue
65
+ }
66
+
67
+ const descriptor = Object.getOwnPropertyDescriptor(source, property)
68
+ if (!descriptor) {
69
+ continue
70
+ }
71
+
72
+ Object.defineProperty(target, property, descriptor)
73
+ }
41
74
  }
@@ -1,5 +1,6 @@
1
1
  import { parse } from 'url'
2
- import { Agent as HttpsAgent } from 'https'
2
+ import { globalAgent as httpGlobalAgent, RequestOptions } from 'http'
3
+ import { Agent as HttpsAgent, globalAgent as httpsGlobalAgent } from 'https'
3
4
  import { getUrlByRequestOptions } from '../../../utils/getUrlByRequestOptions'
4
5
  import { normalizeClientRequestArgs } from './normalizeClientRequestArgs'
5
6
 
@@ -192,8 +193,9 @@ test('handles [URL, RequestOptions, callback] input', () => {
192
193
  expect(url.href).toEqual('https://mswjs.io/resource')
193
194
 
194
195
  // Options must be preserved.
195
- expect(options).toEqual({
196
+ expect(options).toEqual<RequestOptions>({
196
197
  agent: false,
198
+ _defaultAgent: httpsGlobalAgent,
197
199
  protocol: url.protocol,
198
200
  method: 'GET',
199
201
  headers: {
@@ -294,12 +296,11 @@ test('sets fallback Agent based on the URL protocol', () => {
294
296
  'https:',
295
297
  'https://github.com'
296
298
  )
299
+ const agent = options.agent as HttpsAgent
297
300
 
298
- expect(options.agent).toBeInstanceOf(HttpsAgent)
299
- expect(
300
- // @ts-expect-error Protocol is an internal property.
301
- options.agent.protocol
302
- ).toEqual(url.protocol)
301
+ expect(agent).toBeInstanceOf(HttpsAgent)
302
+ expect(agent).toHaveProperty('defaultPort', 443)
303
+ expect(agent).toHaveProperty('protocol', url.protocol)
303
304
  })
304
305
 
305
306
  test('does not set any fallback Agent given "agent: false" option', () => {
@@ -312,6 +313,41 @@ test('does not set any fallback Agent given "agent: false" option', () => {
312
313
  expect(options.agent).toEqual(false)
313
314
  })
314
315
 
316
+ test('sets the default Agent for HTTP request', () => {
317
+ const [, options] = normalizeClientRequestArgs(
318
+ 'http:',
319
+ 'http://github.com',
320
+ {}
321
+ )
322
+
323
+ expect(options._defaultAgent).toEqual(httpGlobalAgent)
324
+ })
325
+
326
+ test('sets the default Agent for HTTPS request', () => {
327
+ const [, options] = normalizeClientRequestArgs(
328
+ 'https:',
329
+ 'https://github.com',
330
+ {}
331
+ )
332
+
333
+ expect(options._defaultAgent).toEqual(httpsGlobalAgent)
334
+ })
335
+
336
+ test('preserves a custom default Agent when set', () => {
337
+ const [, options] = normalizeClientRequestArgs(
338
+ 'https:',
339
+ 'https://github.com',
340
+ {
341
+ /**
342
+ * @note Intentionally incorrect Agent for HTTPS request.
343
+ */
344
+ _defaultAgent: httpGlobalAgent,
345
+ }
346
+ )
347
+
348
+ expect(options._defaultAgent).toEqual(httpGlobalAgent)
349
+ })
350
+
315
351
  test('merges URL-based RequestOptions with the custom RequestOptions', () => {
316
352
  const [url, options] = normalizeClientRequestArgs(
317
353
  'https:',
@@ -1,6 +1,14 @@
1
1
  import { debug } from 'debug'
2
- import { Agent as HttpAgent, IncomingMessage } from 'http'
3
- import { RequestOptions, Agent as HttpsAgent } from 'https'
2
+ import {
3
+ Agent as HttpAgent,
4
+ globalAgent as httpGlobalAgent,
5
+ IncomingMessage,
6
+ } from 'http'
7
+ import {
8
+ RequestOptions,
9
+ Agent as HttpsAgent,
10
+ globalAgent as httpsGlobalAgent,
11
+ } from 'https'
4
12
  import { Url as LegacyURL } from 'url'
5
13
  import { getRequestOptionsByUrl } from '../../../utils/getRequestOptionsByUrl'
6
14
  import {
@@ -198,8 +206,27 @@ export function normalizeClientRequestArgs(
198
206
  log('resolved fallback agent:', agent)
199
207
  }
200
208
 
209
+ /**
210
+ * Ensure that the default Agent is always set.
211
+ * This prevents the protocol mismatch for requests with { agent: false },
212
+ * where the global Agent is inferred.
213
+ * @see https://github.com/mswjs/msw/issues/1150
214
+ * @see https://github.com/nodejs/node/blob/418ff70b810f0e7112d48baaa72932a56cfa213b/lib/_http_client.js#L130
215
+ * @see https://github.com/nodejs/node/blob/418ff70b810f0e7112d48baaa72932a56cfa213b/lib/_http_client.js#L157-L159
216
+ */
217
+ if (!options._defaultAgent) {
218
+ log(
219
+ 'has no default agent, setting the default agent for "%s"',
220
+ options.protocol
221
+ )
222
+
223
+ options._defaultAgent =
224
+ options.protocol === 'https:' ? httpsGlobalAgent : httpGlobalAgent
225
+ }
226
+
201
227
  log('successfully resolved url:', url.href)
202
228
  log('successfully resolved options:', options)
229
+ log('successfully resolved callback:', callback)
203
230
 
204
231
  return [url, options, callback]
205
232
  }
package/src/remote.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ChildProcess, Serializable } from 'child_process'
1
+ import { ChildProcess } from 'child_process'
2
2
  import { Headers } from 'headers-polyfill'
3
3
  import { invariant } from 'outvariant'
4
4
  import { StrictEventEmitter } from 'strict-event-emitter'
@@ -12,8 +12,6 @@ import {
12
12
  } from './createInterceptor'
13
13
  import { toIsoResponse } from './utils/toIsoResponse'
14
14
 
15
- type ProcessEventListener = (message: Serializable, ...args: any[]) => void
16
-
17
15
  export type CreateRemoteInterceptorOptions = Omit<
18
16
  InterceptorOptions,
19
17
  'resolver'
@@ -64,7 +62,7 @@ spawn('node', ['module.js'], { stdio: ['ipc'] })\
64
62
  )
65
63
  }
66
64
 
67
- let handleParentMessage: ProcessEventListener
65
+ let handleParentMessage: NodeJS.MessageListener
68
66
 
69
67
  const interceptor = createInterceptor({
70
68
  ...options,
@@ -73,7 +71,7 @@ spawn('node', ['module.js'], { stdio: ['ipc'] })\
73
71
  process.send?.(`request:${serializedRequest}`)
74
72
 
75
73
  return new Promise((resolve) => {
76
- handleParentMessage = (message: Serializable) => {
74
+ handleParentMessage = (message) => {
77
75
  if (typeof message !== 'string') {
78
76
  return
79
77
  }
@@ -115,7 +113,7 @@ export function createRemoteResolver(
115
113
  ): RemoteResolverApi {
116
114
  const observer = new StrictEventEmitter<InterceptorEventsMap>()
117
115
 
118
- const handleChildMessage: ProcessEventListener = async (message) => {
116
+ const handleChildMessage: NodeJS.MessageListener = async (message) => {
119
117
  if (typeof message !== 'string') {
120
118
  return
121
119
  }