Repository navigation
Conversation
The app's fetchProto slices a fixed data:application/octet-stream;base64, prefix off the readAsDataURL result, while React Native builds that prefix from the blob MIME type taken from the response headers. WuxiaWorld answers with application/grpc-web, whose shorter prefix makes the fixed slice swallow the message frame's first bytes, so protobufjs throws 'illegal tag: field number 0' and parseNovel never resolves. Encode and decode gRPC-web frames with Response.arrayBuffer() instead. Closes lnreader#2830 Co-Authored-By: omp <noreply@omp.local>
[Medium impact] The change affects novel and chapter loading for WuxiaWorld users. The PR appears safe to merge, with a non-blocking issue in locked-chapter warnings. Findings
SummaryReplaces
Reviews (1) · Last reviewed commit: "fix(english/wuxiaworld): decode gRPC-web..." · Reviewed by Greptile |
| if (field === 1 && wireType === 0) { | ||
| info.isChapterUnlocked = readVarint(reader) !== 0; |
There was a problem hiding this comment.
Locked chapters lose their warning
decodeRelatedChapterUserInfo reads isChapterUnlocked as a plain boolean, but the removed schema defines it as a nested BoolValue. If the server sends that wrapper, the decoder skips it and returns {}. This loses the explicit false and also prevents the chapter-number fallback because relatedUserInfo is truthy. Readers then see locked chapters without the 🔒 warning.
Decode the nested BoolValue, including its default false, to preserve the warning.
Root cause
WuxiaWorld only speaks gRPC-web (
api2.wuxiaworld.com), so novel/chapter loading went through@libs/fetch'sfetchProto. The app implementation decodes the response withFileReader.readAsDataURLand slices a fixeddata:application/octet-stream;base64,prefix off the result, but React Native builds that prefix from the blob's own MIME type, which the app's fetch implementation takes from the response headers.WuxiaWorld answers with
application/grpc-web, whose prefix is shorter than the hardcoded one. The fixed slice therefore swallows the first bytes of the protobuf message frame, and protobufjs rejects the payload withillegal tag: field number 0.parseNovelnever resolves, so the novel screen loads forever (#2830). The same failure is why #1679 reported "Can't parse page!" for this plugin.Change
Replaced
fetchProtowith a small gRPC-web frame reader/writer in the plugin (plugins/english/wuxiaworld.ts, v0.5.1 → 0.6.0):GetNovelRequestslug,GetChapterListRequestnovelId,GetChapterRequestnovel+chapter slugs) and sent withResponse-compatibleUint8Arraybodies.response.arrayBuffer(), which returns raw bytes and sidesteps the MIME-prefix bug entirely. Frames with flag0x80(trailers) and malformed/short payloads are ignored rather than thrown, so a bad response yields an empty chapter list instead of an endless spinner.TextDecoderis required in the Hermes runtime.bigintis not used.page, locked-chapter markers againstmaxFreeChapter(default 50), status mapping, release dates, cover/author/genres/summary from the API.Verification
npm run check:plugin -- plugins/english/wuxiaworld.tsagainst the live site:popularNovelssearchNovelsparseNovelparseChapterAlso
eslint,tsc --project tsconfig.production.json, andprettier --checkall clean.Live-check output
Closes #2830