fix: defer module-level side effects to prevent Bun 1.3.5 + macOS 15 segfault (#301)
- Remove eager SG_CLI_PATH constant; use getSgCliPath() lazily in checkEnvironment() - Move setInterval to inside createCommentCheckerHooks() with guard flag These changes eliminate module-level side effects that could trigger segfaults during plugin initialization on Bun 1.3.5 + macOS 15 due to createRequire() being called during module evaluation. Fixes #292 Co-authored-by: sisyphus-dev-ai <sisyphus-dev-ai@users.noreply.github.com>
This commit is contained in:
@@ -21,6 +21,7 @@ const pendingCalls = new Map<string, PendingCall>()
|
||||
const PENDING_CALL_TTL = 60_000
|
||||
|
||||
let cliPathPromise: Promise<string | null> | null = null
|
||||
let cleanupIntervalStarted = false
|
||||
|
||||
function cleanupOldPendingCalls(): void {
|
||||
const now = Date.now()
|
||||
@@ -31,10 +32,13 @@ function cleanupOldPendingCalls(): void {
|
||||
}
|
||||
}
|
||||
|
||||
setInterval(cleanupOldPendingCalls, 10_000)
|
||||
|
||||
export function createCommentCheckerHooks(config?: CommentCheckerConfig) {
|
||||
debugLog("createCommentCheckerHooks called", { config })
|
||||
|
||||
if (!cleanupIntervalStarted) {
|
||||
cleanupIntervalStarted = true
|
||||
setInterval(cleanupOldPendingCalls, 10_000)
|
||||
}
|
||||
|
||||
// Start background CLI initialization (may trigger lazy download)
|
||||
startBackgroundInit()
|
||||
|
||||
Reference in New Issue
Block a user