|
1 | 1 | (function (e, a) { for (var i in a) e[i] = a[i]; }(exports, /******/(function (modules) { // webpackBootstrap |
2 | 2 | /******/ // The module cache |
3 | 3 | /******/ var installedModules = {}; |
4 | | - |
| 4 | +/******/ |
5 | 5 | /******/ // The require function |
6 | 6 | /******/ function __webpack_require__(moduleId) { |
7 | | - |
| 7 | +/******/ |
8 | 8 | /******/ // Check if module is in cache |
9 | | -/******/ if (installedModules[moduleId]) |
| 9 | +/******/ if (installedModules[moduleId]) { |
10 | 10 | /******/ return installedModules[moduleId].exports; |
11 | | - |
| 11 | + /******/ |
| 12 | +} |
12 | 13 | /******/ // Create a new module (and put it into the cache) |
13 | 14 | /******/ var module = installedModules[moduleId] = { |
14 | | -/******/ exports: {}, |
15 | | -/******/ id: moduleId, |
16 | | -/******/ loaded: false |
| 15 | +/******/ i: moduleId, |
| 16 | +/******/ l: false, |
| 17 | +/******/ exports: {} |
17 | 18 | /******/ |
18 | | - }; |
19 | | - |
| 19 | +}; |
| 20 | +/******/ |
20 | 21 | /******/ // Execute the module function |
21 | 22 | /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); |
22 | | - |
| 23 | +/******/ |
23 | 24 | /******/ // Flag the module as loaded |
24 | | -/******/ module.loaded = true; |
25 | | - |
| 25 | +/******/ module.l = true; |
| 26 | +/******/ |
26 | 27 | /******/ // Return the exports of the module |
27 | 28 | /******/ return module.exports; |
28 | 29 | /******/ |
29 | | - } |
30 | | - |
31 | | - |
| 30 | +} |
| 31 | +/******/ |
| 32 | +/******/ |
32 | 33 | /******/ // expose the modules object (__webpack_modules__) |
33 | 34 | /******/ __webpack_require__.m = modules; |
34 | | - |
| 35 | +/******/ |
35 | 36 | /******/ // expose the module cache |
36 | 37 | /******/ __webpack_require__.c = installedModules; |
37 | | - |
| 38 | +/******/ |
| 39 | +/******/ // define getter function for harmony exports |
| 40 | +/******/ __webpack_require__.d = function (exports, name, getter) { |
| 41 | +/******/ if (!__webpack_require__.o(exports, name)) { |
| 42 | +/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); |
| 43 | + /******/ |
| 44 | +} |
| 45 | + /******/ |
| 46 | +}; |
| 47 | +/******/ |
| 48 | +/******/ // define __esModule on exports |
| 49 | +/******/ __webpack_require__.r = function (exports) { |
| 50 | +/******/ if (typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
| 51 | +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
| 52 | + /******/ |
| 53 | +} |
| 54 | +/******/ Object.defineProperty(exports, '__esModule', { value: true }); |
| 55 | + /******/ |
| 56 | +}; |
| 57 | +/******/ |
| 58 | +/******/ // create a fake namespace object |
| 59 | +/******/ // mode & 1: value is a module id, require it |
| 60 | +/******/ // mode & 2: merge all properties of value into the ns |
| 61 | +/******/ // mode & 4: return value when already ns object |
| 62 | +/******/ // mode & 8|1: behave like require |
| 63 | +/******/ __webpack_require__.t = function (value, mode) { |
| 64 | +/******/ if (mode & 1) value = __webpack_require__(value); |
| 65 | +/******/ if (mode & 8) return value; |
| 66 | +/******/ if ((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; |
| 67 | +/******/ var ns = Object.create(null); |
| 68 | +/******/ __webpack_require__.r(ns); |
| 69 | +/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); |
| 70 | +/******/ if (mode & 2 && typeof value != 'string') for (var key in value) __webpack_require__.d(ns, key, function (key) { return value[key]; }.bind(null, key)); |
| 71 | +/******/ return ns; |
| 72 | + /******/ |
| 73 | +}; |
| 74 | +/******/ |
| 75 | +/******/ // getDefaultExport function for compatibility with non-harmony modules |
| 76 | +/******/ __webpack_require__.n = function (module) { |
| 77 | +/******/ var getter = module && module.__esModule ? |
| 78 | +/******/ function getDefault() { return module['default']; } : |
| 79 | +/******/ function getModuleExports() { return module; }; |
| 80 | +/******/ __webpack_require__.d(getter, 'a', getter); |
| 81 | +/******/ return getter; |
| 82 | + /******/ |
| 83 | +}; |
| 84 | +/******/ |
| 85 | +/******/ // Object.prototype.hasOwnProperty.call |
| 86 | +/******/ __webpack_require__.o = function (object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; |
| 87 | +/******/ |
38 | 88 | /******/ // __webpack_public_path__ |
39 | 89 | /******/ __webpack_require__.p = ""; |
40 | | - |
| 90 | +/******/ |
| 91 | +/******/ |
41 | 92 | /******/ // Load entry module and return exports |
42 | | -/******/ return __webpack_require__(0); |
| 93 | +/******/ return __webpack_require__(__webpack_require__.s = 0); |
43 | 94 | /******/ |
44 | 95 | }) |
45 | 96 | /************************************************************************/ |
46 | 97 | /******/([ |
47 | 98 | /* 0 */ |
48 | | -/***/ function (module, exports, __webpack_require__) { |
| 99 | +/***/ (function (module, exports, __webpack_require__) { |
49 | 100 |
|
50 | 101 | module.exports = __webpack_require__(1); |
51 | 102 |
|
52 | 103 |
|
53 | 104 | /***/ |
54 | | - }, |
| 105 | +}), |
55 | 106 | /* 1 */ |
56 | | -/***/ function (module, exports, __webpack_require__) { |
| 107 | +/***/ (function (module, exports, __webpack_require__) { |
57 | 108 |
|
58 | 109 | "use strict"; |
| 110 | + |
| 111 | + exports.__esModule = true; |
59 | 112 | // Limit dependencies to core Node modules. This means the code in this file has to be very low-level and unattractive, |
60 | 113 | // but simplifies things for the consumer of this module. |
61 | 114 | __webpack_require__(2); |
|
119 | 172 | var parsedArgs = ArgsUtil_1.parseArgs(process.argv); |
120 | 173 | var listenAddress = (useWindowsNamedPipes ? '\\\\.\\pipe\\' : '/tmp/') + parsedArgs.listenAddress; |
121 | 174 | server.listen(listenAddress); |
122 | | - ExitWhenParentExits_1.exitWhenParentExits(parseInt(parsedArgs.parentPid)); |
| 175 | + ExitWhenParentExits_1.exitWhenParentExits(parseInt(parsedArgs.parentPid), /* ignoreSigint */ true); |
123 | 176 |
|
124 | 177 |
|
125 | 178 | /***/ |
126 | | - }, |
| 179 | +}), |
127 | 180 | /* 2 */ |
128 | | -/***/ function (module, exports) { |
| 181 | +/***/ (function (module, exports) { |
129 | 182 |
|
130 | 183 | // When Node writes to stdout/strerr, we capture that and convert the lines into calls on the |
131 | 184 | // active .NET ILogger. But by default, stdout/stderr don't have any way of distinguishing |
|
165 | 218 |
|
166 | 219 |
|
167 | 220 | /***/ |
168 | | - }, |
| 221 | +}), |
169 | 222 | /* 3 */ |
170 | | -/***/ function (module, exports) { |
| 223 | +/***/ (function (module, exports) { |
171 | 224 |
|
172 | 225 | module.exports = require("net"); |
173 | 226 |
|
174 | 227 | /***/ |
175 | | - }, |
| 228 | +}), |
176 | 229 | /* 4 */ |
177 | | -/***/ function (module, exports) { |
| 230 | +/***/ (function (module, exports) { |
178 | 231 |
|
179 | 232 | module.exports = require("path"); |
180 | 233 |
|
181 | 234 | /***/ |
182 | | - }, |
| 235 | +}), |
183 | 236 | /* 5 */ |
184 | | -/***/ function (module, exports) { |
| 237 | +/***/ (function (module, exports) { |
185 | 238 |
|
186 | 239 | module.exports = require("readline"); |
187 | 240 |
|
188 | 241 | /***/ |
189 | | - }, |
| 242 | +}), |
190 | 243 | /* 6 */ |
191 | | -/***/ function (module, exports) { |
| 244 | +/***/ (function (module, exports, __webpack_require__) { |
192 | 245 |
|
193 | 246 | "use strict"; |
| 247 | + |
| 248 | + exports.__esModule = true; |
194 | 249 | function parseArgs(args) { |
195 | 250 | // Very simplistic parsing which is sufficient for the cases needed. We don't want to bring in any external |
196 | 251 | // dependencies (such as an args-parsing library) to this file. |
|
213 | 268 |
|
214 | 269 |
|
215 | 270 | /***/ |
216 | | - }, |
| 271 | +}), |
217 | 272 | /* 7 */ |
218 | | -/***/ function (module, exports) { |
| 273 | +/***/ (function (module, exports, __webpack_require__) { |
| 274 | + |
| 275 | + "use strict"; |
219 | 276 |
|
220 | 277 | /* |
221 | 278 | In general, we want the Node child processes to be terminated as soon as the parent .NET processes exit, |
222 | 279 | because we have no further use for them. If the .NET process shuts down gracefully, it will run its |
223 | 280 | finalizers, one of which (in OutOfProcessNodeInstance.cs) will kill its associated Node process immediately. |
224 | | - |
| 281 | + |
225 | 282 | But if the .NET process is terminated forcefully (e.g., on Linux/OSX with 'kill -9'), then it won't have |
226 | 283 | any opportunity to shut down its child processes, and by default they will keep running. In this case, it's |
227 | 284 | up to the child process to detect this has happened and terminate itself. |
228 | | - |
| 285 | + |
229 | 286 | There are many possible approaches to detecting when a parent process has exited, most of which behave |
230 | 287 | differently between Windows and Linux/OS X: |
231 | | - |
| 288 | + |
232 | 289 | - On Windows, the parent process can mark its child as being a 'job' that should auto-terminate when |
233 | 290 | the parent does (http://stackoverflow.com/a/4657392). Not cross-platform. |
234 | 291 | - The child Node process can get a callback when the parent disconnects (process.on('disconnect', ...)). |
|
246 | 303 | However I don't see this documented anywhere. It would be nice if you could just poll for whether or not |
247 | 304 | process.stdout is still connected (without actually writing to it) but I haven't found any property whose |
248 | 305 | value changes until you actually try to write to it. |
249 | | - |
| 306 | + |
250 | 307 | Of these, the only cross-platform approach that is actually documented as a valid strategy is simply polling |
251 | 308 | to check whether the parent PID is still running. So that's what we do here. |
252 | 309 | */ |
253 | | - "use strict"; |
| 310 | + exports.__esModule = true; |
254 | 311 | var pollIntervalMs = 1000; |
255 | | - function exitWhenParentExits(parentPid) { |
| 312 | + function exitWhenParentExits(parentPid, ignoreSigint) { |
256 | 313 | setInterval(function () { |
257 | 314 | if (!processExists(parentPid)) { |
258 | 315 | // Can't log anything at this point, because out stdout was connected to the parent, |
259 | 316 | // but the parent is gone. |
260 | 317 | process.exit(); |
261 | 318 | } |
262 | 319 | }, pollIntervalMs); |
| 320 | + if (ignoreSigint) { |
| 321 | + // Pressing ctrl+c in the terminal sends a SIGINT to all processes in the foreground process tree. |
| 322 | + // By default, the Node process would then exit before the .NET process, because ASP.NET implements |
| 323 | + // a delayed shutdown to allow ongoing requests to complete. |
| 324 | + // |
| 325 | + // This is problematic, because if Node exits first, the CopyToAsync code in ConditionalProxyMiddleware |
| 326 | + // will experience a read fault, and logs a huge load of errors. Fortunately, since the Node process is |
| 327 | + // already set up to shut itself down if it detects the .NET process is terminated, all we have to do is |
| 328 | + // ignore the SIGINT. The Node process will then terminate automatically after the .NET process does. |
| 329 | + // |
| 330 | + // A better solution would be to have WebpackDevMiddleware listen for SIGINT and gracefully close any |
| 331 | + // ongoing EventSource connections before letting the Node process exit, independently of the .NET |
| 332 | + // process exiting. However, doing this well in general is very nontrivial (see all the discussion at |
| 333 | + // https://github.com/nodejs/node/issues/2642). |
| 334 | + process.on('SIGINT', function () { |
| 335 | + console.log('Received SIGINT. Waiting for .NET process to exit...'); |
| 336 | + }); |
| 337 | + } |
263 | 338 | } |
264 | 339 | exports.exitWhenParentExits = exitWhenParentExits; |
265 | 340 | function processExists(pid) { |
|
281 | 356 |
|
282 | 357 |
|
283 | 358 | /***/ |
284 | | - }, |
| 359 | +}), |
285 | 360 | /* 8 */ |
286 | | -/***/ function (module, exports, __webpack_require__) { |
| 361 | +/***/ (function (module, exports, __webpack_require__) { |
287 | 362 |
|
288 | 363 | "use strict"; |
| 364 | + |
| 365 | + exports.__esModule = true; |
289 | 366 | var events_1 = __webpack_require__(9); |
290 | 367 | var VirtualConnection_1 = __webpack_require__(10); |
291 | 368 | // Keep this in sync with the equivalent constant in the .NET code. Both sides split up their transmissions into frames with this max length, |
|
311 | 388 | /** |
312 | 389 | * Tracks the 'virtual connections' associated with a single physical socket connection. |
313 | 390 | */ |
314 | | - var VirtualConnectionsCollection = (function () { |
| 391 | + var VirtualConnectionsCollection = /** @class */ (function () { |
315 | 392 | function VirtualConnectionsCollection(_socket, _onVirtualConnectionCallback) { |
316 | 393 | var _this = this; |
317 | 394 | this._socket = _socket; |
|
393 | 470 | newVirtualConnection.on('finish', function () { |
394 | 471 | // The virtual connection was closed locally. Clean up locally, and notify the remote that we're done. |
395 | 472 | _this._onVirtualConnectionWasClosed(header.connectionIdString); |
396 | | - _this._sendFrame(header.connectionIdBinary, Buffer.alloc(0)); |
| 473 | + _this._sendFrame(header.connectionIdBinary, new Buffer(0)); |
397 | 474 | }); |
398 | 475 | this._virtualConnections[header.connectionIdString] = newVirtualConnection; |
399 | 476 | this._onVirtualConnectionCallback(newVirtualConnection); |
|
455 | 532 | * Sends a number serialized in the correct format for .NET to receive as a System.Int32 |
456 | 533 | */ |
457 | 534 | VirtualConnectionsCollection.prototype._sendInt32LE = function (value, callback) { |
458 | | - var buf = Buffer.alloc(4); |
| 535 | + var buf = new Buffer(4); |
459 | 536 | buf.writeInt32LE(value, 0); |
460 | 537 | this._socket.write(buf, callback); |
461 | 538 | }; |
|
469 | 546 |
|
470 | 547 |
|
471 | 548 | /***/ |
472 | | - }, |
| 549 | +}), |
473 | 550 | /* 9 */ |
474 | | -/***/ function (module, exports) { |
| 551 | +/***/ (function (module, exports) { |
475 | 552 |
|
476 | 553 | module.exports = require("events"); |
477 | 554 |
|
478 | 555 | /***/ |
479 | | - }, |
| 556 | +}), |
480 | 557 | /* 10 */ |
481 | | -/***/ function (module, exports, __webpack_require__) { |
| 558 | +/***/ (function (module, exports, __webpack_require__) { |
482 | 559 |
|
483 | 560 | "use strict"; |
484 | | - var __extends = (this && this.__extends) || function (d, b) { |
485 | | - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; |
486 | | - function __() { this.constructor = d; } |
487 | | - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); |
488 | | - }; |
| 561 | + |
| 562 | + var __extends = (this && this.__extends) || (function () { |
| 563 | + var extendStatics = function (d, b) { |
| 564 | + extendStatics = Object.setPrototypeOf || |
| 565 | + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || |
| 566 | + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; |
| 567 | + return extendStatics(d, b); |
| 568 | + } |
| 569 | + return function (d, b) { |
| 570 | + extendStatics(d, b); |
| 571 | + function __() { this.constructor = d; } |
| 572 | + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); |
| 573 | + }; |
| 574 | + })(); |
| 575 | + exports.__esModule = true; |
489 | 576 | var stream_1 = __webpack_require__(11); |
490 | 577 | /** |
491 | 578 | * Represents a virtual connection. Multiple virtual connections may be multiplexed over a single physical socket connection. |
492 | 579 | */ |
493 | | - var VirtualConnection = (function (_super) { |
| 580 | + var VirtualConnection = /** @class */ (function (_super) { |
494 | 581 | __extends(VirtualConnection, _super); |
495 | 582 | function VirtualConnection(_beginWriteCallback) { |
496 | 583 | var _this = _super.call(this) || this; |
|
510 | 597 | }; |
511 | 598 | VirtualConnection.prototype._write = function (chunk, encodingIfString, callback) { |
512 | 599 | if (typeof chunk === 'string') { |
513 | | - chunk = Buffer.from(chunk, encodingIfString); |
| 600 | + chunk = new Buffer(chunk, encodingIfString); |
514 | 601 | } |
515 | 602 | this._beginWriteCallback(chunk, callback); |
516 | 603 | }; |
|
528 | 615 |
|
529 | 616 |
|
530 | 617 | /***/ |
531 | | - }, |
| 618 | +}), |
532 | 619 | /* 11 */ |
533 | | -/***/ function (module, exports) { |
| 620 | +/***/ (function (module, exports) { |
534 | 621 |
|
535 | 622 | module.exports = require("stream"); |
536 | 623 |
|
537 | 624 | /***/ |
538 | | - } |
| 625 | +}) |
539 | 626 | /******/]))); |
0 commit comments