-
Notifications
You must be signed in to change notification settings - Fork 1
RDKEMW-24812: DefaultMessageDispatcher stops after 5-10 minutes of pl… #144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,7 +20,7 @@ | |
|
|
||
| var callBind = __webpack_require__(870); | ||
|
|
||
| var $indexOf = callBind(GetIntrinsic('String.prototype.indexOf')); | ||
|
Check failure on line 23 in src/jsc/modules/node-fetch.js
|
||
|
|
||
| module.exports = function callBoundIntrinsic(name, allowMissing) { | ||
| var intrinsic = GetIntrinsic(name, !!allowMissing); | ||
|
|
@@ -330,7 +330,7 @@ | |
| }; | ||
|
|
||
|
|
||
| /***/ }), | ||
|
Check failure on line 333 in src/jsc/modules/node-fetch.js
|
||
|
|
||
| /***/ 437: | ||
| /***/ ((module) => { | ||
|
|
@@ -1031,7 +1031,7 @@ | |
| //MADANA HACK | ||
| //var zlib = _interopDefault(require('zlib')); | ||
|
|
||
| // Based on https://github.com/tmpvar/jsdom/blob/aa85b2abf07766ff7bf5c1f6daafb3726f2f2db5/lib/jsdom/living/blob.js | ||
|
Check failure on line 1034 in src/jsc/modules/node-fetch.js
|
||
|
|
||
| // fix for "Readable" isn't a named export issue | ||
| const Readable = Stream.Readable; | ||
|
|
@@ -1188,6 +1188,44 @@ | |
| // fix an issue where "PassThrough" isn't a named export for node <10 | ||
| const PassThrough = Stream.PassThrough; | ||
|
|
||
| function isStreamLike(body) { | ||
| return !!body | ||
| && typeof body.on === 'function' | ||
| && (typeof body.pipe === 'function' || typeof body.once === 'function'); | ||
|
gurpreet319 marked this conversation as resolved.
|
||
| } | ||
|
|
||
| function getErrorReason(err) { | ||
| if (!err) { | ||
| return 'unknown error'; | ||
| } | ||
|
|
||
| if (typeof err === 'string') { | ||
| return err; | ||
| } | ||
|
|
||
| if (err.message) { | ||
| return err.message; | ||
| } | ||
|
|
||
| if (err.description) { | ||
| return err.description; | ||
| } | ||
|
|
||
| if (err.reason) { | ||
| return err.reason; | ||
| } | ||
|
|
||
| if (err.code !== undefined) { | ||
| return 'code: ' + err.code; | ||
| } | ||
|
|
||
| try { | ||
| return JSON.stringify(err); | ||
| } catch (e) { | ||
| return String(err); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Body mixin | ||
| * | ||
|
|
@@ -1219,7 +1257,7 @@ | |
| } else if (ArrayBuffer.isView(body)) { | ||
| // body is ArrayBufferView | ||
| body = Buffer.from(body.buffer, body.byteOffset, body.byteLength); | ||
| } else if (body instanceof Stream) ; else { | ||
| } else if (body instanceof Stream || isStreamLike(body)) ; else { | ||
| // none of the above | ||
| // coerce to string then buffer | ||
| //body = Buffer.from(String(body)); | ||
|
|
@@ -1234,7 +1272,7 @@ | |
| this.size = size; | ||
| this.timeout = timeout; | ||
|
|
||
| if (body instanceof Stream) { | ||
| if (body instanceof Stream || isStreamLike(body)) { | ||
| body.on('error', function (err) { | ||
| const error = err.name === 'AbortError' ? err : new FetchError(`Invalid response body while trying to fetch ${_this.url}: ${err.message}`, 'system', err); | ||
| _this[INTERNALS].error = error; | ||
|
|
@@ -1289,8 +1327,12 @@ | |
| var _this2 = this; | ||
|
|
||
| return consumeBody.call(this).then(function (buffer) { | ||
| var text = buffer.toString(); | ||
| if (text.trim() === '') { | ||
| return {}; | ||
| } | ||
|
gurpreet319 marked this conversation as resolved.
|
||
| try { | ||
| return JSON.parse(buffer.toString()); | ||
| return JSON.parse(text); | ||
| } catch (err) { | ||
| return Body.Promise.reject(new FetchError(`invalid json response body at ${_this2.url} reason: ${err.message}`, 'invalid-json')); | ||
| } | ||
|
|
@@ -1390,7 +1432,7 @@ | |
| } | ||
|
|
||
| // istanbul ignore if: should never happen | ||
| if (!(body instanceof Stream)) { | ||
| if (!(body instanceof Stream) && !isStreamLike(body)) { | ||
| return Body.Promise.resolve(Buffer.alloc(0)); | ||
| } | ||
|
|
||
|
|
@@ -1419,7 +1461,7 @@ | |
| reject(err); | ||
| } else { | ||
| // other errors, such as incorrect content-encoding | ||
| reject(new FetchError(`Invalid response body while trying to fetch ${_this4.url}: ${err.message}`, 'system', err)); | ||
| reject(new FetchError(`Invalid response body while trying to fetch ${_this4.url}: ${getErrorReason(err)}`, 'system', err)); | ||
| } | ||
| }); | ||
|
|
||
|
|
@@ -1428,6 +1470,10 @@ | |
| return; | ||
| } | ||
|
|
||
| if (!Buffer.isBuffer(chunk)) { | ||
| chunk = Buffer.from(chunk); | ||
| } | ||
|
|
||
| if (_this4.size && accumBytes + chunk.length > _this4.size) { | ||
| abort = true; | ||
| reject(new FetchError(`content size at ${_this4.url} over limit: ${_this4.size}`, 'max-size')); | ||
|
|
@@ -1564,6 +1610,9 @@ | |
| // check that body is a stream and not form-data object | ||
| // note: we can't clone the form-data object without having it as a dependency | ||
| if (body instanceof Stream && typeof body.getBoundary !== 'function') { | ||
| if (typeof PassThrough !== 'function') { | ||
| throw new Error('cannot clone body stream: PassThrough is not available in this runtime'); | ||
|
gurpreet319 marked this conversation as resolved.
|
||
| } | ||
| // tee instance body | ||
| p1 = new PassThrough(); | ||
| p2 = new PassThrough(); | ||
|
|
@@ -2444,6 +2493,7 @@ | |
|
|
||
| // fix an issue where "PassThrough", "resolve" aren't a named export for node <10 | ||
| const PassThrough$1 = Stream.PassThrough; | ||
| const hasPassThrough$1 = typeof PassThrough$1 === 'function'; | ||
|
|
||
| const isDomainOrSubdomain = function isDomainOrSubdomain(destination, original) { | ||
| const orig = new URL$1(original).hostname; | ||
|
|
@@ -2527,17 +2577,15 @@ | |
| clearTimeout(reqTimeout); | ||
| } | ||
|
|
||
| if (request.timeout) { | ||
| req.once('socket', function (socket) { | ||
| reqTimeout = setTimeout(function () { | ||
| reject(new FetchError(`network timeout at: ${request.url}`, 'request-timeout')); | ||
| finalize(); | ||
| }, request.timeout); | ||
| }); | ||
| } | ||
| if (request.timeout) { | ||
| reqTimeout = setTimeout(function () { | ||
| reject(new FetchError(`network timeout at: ${request.url}`, 'request-timeout')); | ||
| finalize(); | ||
| }, request.timeout); | ||
| } | ||
|
|
||
| req.on('error', function (err) { | ||
| reject(new FetchError(`request to ${request.url} failed, reason: ${err.message}`, 'system', err)); | ||
| reject(new FetchError(`request to ${request.url} failed, reason: ${getErrorReason(err)}`, 'system', err)); | ||
|
|
||
| if (response && response.body) { | ||
| destroyStream(response.body, err); | ||
|
|
@@ -2678,15 +2726,8 @@ | |
| } | ||
| } | ||
|
|
||
| //MADANA HACK | ||
| let body = undefined; | ||
| // prepare response | ||
| res.once('data', function (data) { | ||
| body = data; | ||
| }); | ||
| res.once('end', function () { | ||
| if (signal) signal.removeEventListener('abort', abortAndFinalize); | ||
| //let body = res.pipe(new PassThrough$1()); | ||
| if (signal) signal.removeEventListener('abort', abortAndFinalize); | ||
| let body = hasPassThrough$1 ? res.pipe(new PassThrough$1()) : res; | ||
|
gurpreet319 marked this conversation as resolved.
|
||
|
|
||
| const response_options = { | ||
| url: request.url, | ||
|
|
@@ -2709,7 +2750,7 @@ | |
| // 3. no Content-Encoding header | ||
| // 4. no content response (204) | ||
| // 5. content not modified response (304) | ||
| if (!request.compress || request.method === 'HEAD' || codings === null || res.statusCode === 204 || res.statusCode === 304) { | ||
| if (!request.compress || request.method === 'HEAD' || codings === null || res.statusCode === 204 || res.statusCode === 304) { | ||
| response = new Response(body, response_options); | ||
| resolve(response); | ||
| return; | ||
|
|
@@ -2740,6 +2781,12 @@ | |
|
|
||
| // for deflate | ||
| if (codings == 'deflate' || codings == 'x-deflate') { | ||
| if (!hasPassThrough$1) { | ||
| body = body.pipe(zlib.createInflate()); | ||
| response = new Response(body, response_options); | ||
| resolve(response); | ||
| return; | ||
| } | ||
| // handle the infamous raw deflate response from old servers | ||
| // a hack for old IIS and Apache servers | ||
| const raw = res.pipe(new PassThrough$1()); | ||
|
|
@@ -2776,11 +2823,9 @@ | |
| console.warn(`[DEBUG] Content-Encoding '${codings}' detected but zlib not available for decompression`); | ||
| } | ||
| } | ||
| // otherwise, use response as-is | ||
| response = new Response(body, response_options); | ||
| console.log(response); | ||
| resolve(response); | ||
| }); | ||
| // otherwise, use response as-is | ||
| response = new Response(body, response_options); | ||
| resolve(response); | ||
| }); | ||
|
|
||
| writeToStream(req, request); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.