Symptom
Opening any PDF fails. The renderer console shows:
Fetch API cannot load knownote-doc://docs/doc_...: URL scheme "knownote-doc" is not supported.
Failed to open PDF TypeError: Failed to fetch. URL scheme "knownote-doc" is not supported.
The whole reader is dead. Introduced by #131 (the CJK asset fix).
Root cause
protocol.registerSchemesAsPrivileged() replaces the privilege table; it does not append. #131 added a second, separate call:
registerDocumentScheme() // knownote-doc
registerPdfjsAssetScheme() // knownote-asset ← overwrites the table
so knownote-doc lost supportFetchAPI and the renderer's fetch() on it failed. protocol.handle itself keeps working in the main process, which is why nothing else noticed.
The packaged smoke test did not catch it because its knownote-doc:// check ran through the main process (net.fetch), which does not need the renderer-facing privilege.
Fix
- Protocol modules only declare their scheme (
declareDocumentScheme() / declarePdfjsAssetScheme()).
privilegedSchemes.ts::applyPrivilegedSchemes() performs the single registerSchemesAsPrivileged() call, invoked once from index.ts before the app is ready.
smokeTest now also fetches knownote-doc:// from a real renderer, which is the level at which this broke.
Acceptance
Related
Symptom
Opening any PDF fails. The renderer console shows:
The whole reader is dead. Introduced by #131 (the CJK asset fix).
Root cause
protocol.registerSchemesAsPrivileged()replaces the privilege table; it does not append. #131 added a second, separate call:so
knownote-doclostsupportFetchAPIand the renderer'sfetch()on it failed.protocol.handleitself keeps working in the main process, which is why nothing else noticed.The packaged smoke test did not catch it because its
knownote-doc://check ran through the main process (net.fetch), which does not need the renderer-facing privilege.Fix
declareDocumentScheme()/declarePdfjsAssetScheme()).privilegedSchemes.ts::applyPrivilegedSchemes()performs the singleregisterSchemesAsPrivileged()call, invoked once fromindex.tsbefore the app is ready.smokeTestnow also fetchesknownote-doc://from a real renderer, which is the level at which this broke.Acceptance
knownote-doc://andknownote-asset://are fetchable from the rendererregisterSchemesAsPrivileged()call site insrc/smoke:packagedfails if the document scheme loses its privilegeRelated