Skip to content

Commit 1f6cb12

Browse files
committed
Filter rcedit input to Windows PE binaries only
The Windows packaging step runs rcedit.exe over every *.node file under the bundled node_modules to stamp PE metadata. rcedit only understands Windows PE format and crashes on Mach-O / ELF cross-platform prebuilds shipped by copilot transitive deps (claude-agent-sdk audio-capture, foundry-local-sdk, @picovoice/pvrecorder-node, @github/copilot/sdk/ prebuilds, etc.). Check the first two magic bytes (MZ = 0x4D 0x5A) before invoking rcedit and skip files that aren't Windows PE. Kills the entire class of bug without per-package .moduleignore maintenance. Same fix applied in the REH (server) build path. Removes the three reactive .moduleignore entries added over the last 24 hours; they're now redundant.
1 parent 6cbe7ff commit 1f6cb12

3 files changed

Lines changed: 33 additions & 17 deletions

File tree

build/.moduleignore

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -243,18 +243,3 @@ zone.js/dist/**
243243
# in websocket's browser.js inside a try/catch with a globalThis fallback,
244244
# so it is unnecessary in the browsers/runtimes VS Code supports.
245245
es5-ext/**
246-
247-
# claude-agent-sdk ships per-platform audio-capture .node binaries under
248-
# vendor/audio-capture/{arch-platform}/. Non-Windows binaries break Windows
249-
# packaging because rcedit only understands Windows PE format.
250-
@anthropic-ai/claude-agent-sdk/vendor/audio-capture/**
251-
252-
# foundry-local-sdk ships per-platform .node binaries under prebuilds/.
253-
# Same rcedit incompatibility as above.
254-
foundry-local-sdk/prebuilds/**
255-
256-
# @picovoice/pvrecorder-node (nested under @github/copilot/pvrecorder) ships
257-
# pv_recorder.node binaries under lib/{mac,linux,windows}/. Keep windows/ so
258-
# the Windows build retains its native binary; strip the rest.
259-
@picovoice/pvrecorder-node/lib/mac/**
260-
@picovoice/pvrecorder-node/lib/linux/**

build/gulpfile.reh.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,8 +443,23 @@ function patchWin32DependenciesTask(destinationFolderName: string) {
443443

444444
const patchPromises = deps.map<Promise<unknown>>(async dep => {
445445
const basename = path.basename(dep);
446+
const fullPath = path.join(cwd, dep);
447+
448+
// Roopik: rcedit.exe only handles Windows PE-format binaries. Skip any
449+
// file whose first two bytes are not 'MZ' (Mach-O / ELF prebuilds from
450+
// cross-platform deps would otherwise crash the packaging step).
451+
const handle = await fs.promises.open(fullPath, 'r');
452+
try {
453+
const header = Buffer.alloc(2);
454+
await handle.read(header, 0, 2, 0);
455+
if (header[0] !== 0x4D || header[1] !== 0x5A) {
456+
return;
457+
}
458+
} finally {
459+
await handle.close();
460+
}
446461

447-
await rcedit(path.join(cwd, dep), {
462+
await rcedit(fullPath, {
448463
'file-version': baseVersion,
449464
'version-string': {
450465
'CompanyName': 'Microsoft Corporation',

build/gulpfile.vscode.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,8 +556,24 @@ function patchWin32DependenciesTask(destinationFolderName: string) {
556556

557557
const patchPromises = deps.map<Promise<unknown>>(async dep => {
558558
const basename = path.basename(dep);
559+
const fullPath = path.join(cwd, dep);
560+
561+
// Roopik: rcedit.exe only handles Windows PE-format binaries. Skip any
562+
// file whose first two bytes are not 'MZ' (e.g. Mach-O / ELF prebuilds
563+
// shipped by cross-platform deps such as @github/copilot,
564+
// @picovoice/pvrecorder-node, foundry-local-sdk, etc.).
565+
const handle = await fs.promises.open(fullPath, 'r');
566+
try {
567+
const header = Buffer.alloc(2);
568+
await handle.read(header, 0, 2, 0);
569+
if (header[0] !== 0x4D || header[1] !== 0x5A) {
570+
return;
571+
}
572+
} finally {
573+
await handle.close();
574+
}
559575

560-
await rcedit(path.join(cwd, dep), {
576+
await rcedit(fullPath, {
561577
'file-version': baseVersion,
562578
'version-string': {
563579
'CompanyName': 'Microsoft Corporation',

0 commit comments

Comments
 (0)