source: imaps-frontend/node_modules/webpack/hot/lazy-compilation-node.js

main
Last change on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 4 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 1.2 KB
Line 
1/* global __resourceQuery */
2
3"use strict";
4
5var urlBase = decodeURIComponent(__resourceQuery.slice(1));
6
7/**
8 * @param {{ data: string, onError: (err: Error) => void, active: boolean, module: module }} options options
9 * @returns {() => void} function to destroy response
10 */
11exports.keepAlive = function (options) {
12 var data = options.data;
13 var onError = options.onError;
14 var active = options.active;
15 var module = options.module;
16 /** @type {import("http").IncomingMessage} */
17 var response;
18 var request = (
19 urlBase.startsWith("https") ? require("https") : require("http")
20 ).request(
21 urlBase + data,
22 {
23 agent: false,
24 headers: { accept: "text/event-stream" }
25 },
26 function (res) {
27 response = res;
28 response.on("error", errorHandler);
29 if (!active && !module.hot) {
30 console.log(
31 "Hot Module Replacement is not enabled. Waiting for process restart..."
32 );
33 }
34 }
35 );
36
37 /**
38 * @param {Error} err error
39 */
40 function errorHandler(err) {
41 err.message =
42 "Problem communicating active modules to the server: " + err.message;
43 onError(err);
44 }
45 request.on("error", errorHandler);
46 request.end();
47 return function () {
48 response.destroy();
49 };
50};
Note: See TracBrowser for help on using the repository browser.