chore: delay load pdfjs-dist for pdf spec (#48888)

trap handlers will be initialized once the user script starts
but before app#ready. Wasm compilation before that phase will
break trap handler registeration due to the check in
v8::internal::wasm::UpdateComputedInformation. For some reason
this issue was only visible in <= 39-x-y when pdf-reader.mjs
was being loaded, maybe some module loading logic changed in >= 40-x-y
which are based on Node.js v24.x. In either case, it is best to
align the loading of wasm module required for the tests in light
of changes to how we are registering the trap handlers for the
main process.
This commit is contained in:
Robo
2025-11-11 19:00:39 +09:00
committed by GitHub
parent b659563724
commit f260e06a62

View File

@@ -1,7 +1,8 @@
import * as pdfjs from 'pdfjs-dist';
import { app } from 'electron';
async function getPDFDoc () {
try {
const pdfjs = await import('pdfjs-dist');
const doc = await pdfjs.getDocument(process.argv[2]).promise;
const page = await doc.getPage(1);
const { items } = await page.getTextContent();
@@ -20,4 +21,4 @@ async function getPDFDoc () {
}
}
getPDFDoc();
app.whenReady().then(() => getPDFDoc());