Skip to content

Commit 0efd9fb

Browse files
plossonclaude
andcommitted
fix: add protobufjs Long polyfill for native binary compilation
Bun's native compilation doesn't handle protobufjs dynamic Long loading. Pre-initialize protobuf.util.Long before Baileys import to fix runtime error. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent c8aba72 commit 0efd9fb

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/usr/bin/env bun
2+
// Polyfills must be imported first (before any code that uses protobufjs)
3+
import './polyfills';
24
import { Command } from 'commander';
35
import { registerGmailCommands } from './commands/gmail';
46
import { registerGDocsCommands } from './commands/gdocs';

src/polyfills.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Polyfills for native binary compilation
2+
// This must be imported BEFORE any code that uses protobufjs (e.g., Baileys)
3+
4+
import Long from 'long';
5+
import protobuf from 'protobufjs';
6+
7+
// Fix for protobufjs Long support in Bun native binaries
8+
// Without this, $util.Long.fromBits is undefined at runtime
9+
protobuf.util.Long = Long;
10+
protobuf.configure();

0 commit comments

Comments
 (0)