{"record":{"id":"c05d425103ab727c","repo":"bilibili/flv.js","slug":"mozchunkedloader-http-code-invalid-xhr-statu","errorCode":null,"errorMessage":"MozChunkedLoader: Http code invalid, ' + xhr.status + ' ' + xhr.statusText","messagePattern":"MozChunkedLoader: Http code invalid, ' \\+ xhr\\.status \\+ ' ' \\+ xhr\\.statusText","errorType":"http","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/io/xhr-moz-chunked-loader.js","lineNumber":143,"sourceCode":"    }\n\n    _onReadyStateChange(e) {\n        let xhr = e.target;\n\n        if (xhr.readyState === 2) {  // HEADERS_RECEIVED\n            if (xhr.responseURL != undefined && xhr.responseURL !== this._requestURL) {\n                if (this._onURLRedirect) {\n                    let redirectedURL = this._seekHandler.removeURLParameters(xhr.responseURL);\n                    this._onURLRedirect(redirectedURL);\n                }\n            }\n\n            if (xhr.status !== 0 && (xhr.status < 200 || xhr.status > 299)) {\n                this._status = LoaderStatus.kError;\n                if (this._onError) {\n                    this._onError(LoaderErrors.HTTP_STATUS_CODE_INVALID, {code: xhr.status, msg: xhr.statusText});\n                } else {\n                    throw new RuntimeException('MozChunkedLoader: Http code invalid, ' + xhr.status + ' ' + xhr.statusText);\n                }\n            } else {\n                this._status = LoaderStatus.kBuffering;\n            }\n        }\n    }\n\n    _onProgress(e) {\n        if (this._status === LoaderStatus.kError) {\n            // Ignore error response\n            return;\n        }\n\n        if (this._contentLength === null) {\n            if (e.total !== null && e.total !== 0) {\n                this._contentLength = e.total;\n                if (this._onContentLengthKnown) {\n                    this._onContentLengthKnown(this._contentLength);","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/bilibili/flv.js/blob/42343088f22619cf014a057b3878fe3d320016a6/src/io/xhr-moz-chunked-loader.js#L125-L161","documentation":"MozChunkedLoader (Firefox moz-chunked-xhr path) checks the HTTP status at readyState 2 (HEADERS_RECEIVED). Any status outside 200-299 (and not 0) is treated as a fatal load error: the loader enters kError and, if no onError callback is set, throws RuntimeException including the numeric status and statusText.","triggerScenarios":"The XHR for the FLV stream completes headers with a non-2xx status — e.g. 404 for a removed file, 403 for expired/missing auth token, 5xx from an overloaded server — in _onReadyStateChange (src/io/xhr-moz-chunked-loader.js:143).","commonSituations":"Expired signed CDN URLs, wrong stream path, CORS/auth failures, or the stream URL pointing to an error page instead of media; commonly seen in Firefox only since this loader is the Firefox code path.","solutions":["Check the reported status/statusText and fix the server side: verify the FLV URL exists (curl -I) and permissions/tokens are valid.","Register onError to receive LoaderErrors.HTTP_STATUS_CODE_INVALID instead of an uncaught throw.","Refresh or re-sign the CDN URL and retry; add fallback URL logic."],"exampleFix":"// before\nplayer.load(); // 403 from expired token not handled\n// after\nplayer.on(flvjs.Events.ERROR, (type, data) => {\n    if (data.code === 403) refreshSignedUrlAndReload();\n});","handlingStrategy":"try-catch","validationCode":"// Pre-flight check before starting Firefox chunked load\nfetch(streamUrl, {method: 'HEAD'}).then(r => {\n    if (!r.ok) throw new Error('Stream URL not reachable: ' + r.status);\n    startPlayer();\n});","typeGuard":null,"tryCatchPattern":"try {\n    player.load();\n} catch (e) {\n    if (/MozChunkedLoader: Http code invalid/.test(e.message)) {\n        const m = e.message.match(/invalid, (\\d+)/);\n        handleHttpFailure(m ? Number(m[1]) : 0);\n    } else throw e;\n}","preventionTips":["HEAD-check the FLV URL before load and fail fast with a clear UI message.","Keep signed CDN URLs refreshed before expiry.","Register onError so HTTP_STATUS_CODE_INVALID is handled, not thrown.","Maintain a fallback CDN URL for automatic failover."],"tags":["http","network","loader","firefox"],"backgroundTag":"invalid-http-status-code","analyzedSha":"42343088f22619cf014a057b3878fe3d320016a6","analyzedAt":"2026-09-01T00:27:28.147Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}