fix: defer module-level side effects to prevent Bun 1.3.5 + macOS 15 segfault#301
Merged
Conversation
…segfault - 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
Greptile SummaryFixes segmentation fault on Bun 1.3.5 + macOS 15 by deferring module-level side effects to runtime. Key Changes:
Root Cause: Impact:
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Bun as Bun Runtime
participant Plugin as Plugin Module
participant AstGrep as ast-grep/constants
participant CommentChecker as comment-checker
Note over Bun,CommentChecker: BEFORE (Segfault Scenario)
Bun->>Plugin: Import oh-my-opencode
Plugin->>AstGrep: Module evaluation
AstGrep->>AstGrep: const SG_CLI_PATH = getSgCliPath()
AstGrep->>AstGrep: findSgCliPathSync()
AstGrep->>AstGrep: createRequire(import.meta.url)
Note right of AstGrep: ⚠️ Segfault on Bun 1.3.5 + macOS 15
AstGrep--xBun: CRASH
Note over Bun,CommentChecker: AFTER (Fixed)
Bun->>Plugin: Import oh-my-opencode
Plugin->>AstGrep: Module evaluation
Note right of AstGrep: ✅ No eager initialization
Plugin->>CommentChecker: Module evaluation
Note right of CommentChecker: ✅ No setInterval at module level
Plugin->>Plugin: Initialize plugin (ctx)
Plugin->>CommentChecker: createCommentCheckerHooks()
CommentChecker->>CommentChecker: Start cleanup interval (guarded)
Plugin->>AstGrep: checkEnvironment() [user calls]
AstGrep->>AstGrep: getSgCliPath() [first use]
AstGrep->>AstGrep: findSgCliPathSync()
AstGrep->>AstGrep: createRequire(import.meta.url)
Note right of AstGrep: ✅ Safe after module init complete
AstGrep-->>Plugin: CLI path resolved
|
Owner
|
@sisyphus-dev-ai resolve conflicts |
Collaborator
Author
|
👋 Hey @code-yeongyu! I'm on it... |
Merged config parameter from dev (feat: pass custom_prompt to CLI) while preserving the lazy initialization fix from this PR to prevent Bun 1.3.5 + macOS 15 segfault.
sssgun
pushed a commit
to sssgun/oh-my-opencode
that referenced
this pull request
Jan 18, 2026
…segfault (code-yeongyu#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 code-yeongyu#292 Co-authored-by: sisyphus-dev-ai <sisyphus-dev-ai@users.noreply.github.com>
Rolloniel
pushed a commit
to Rolloniel/oh-my-opencode
that referenced
this pull request
Feb 22, 2026
…segfault (code-yeongyu#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 code-yeongyu#292 Co-authored-by: sisyphus-dev-ai <sisyphus-dev-ai@users.noreply.github.com>
luobosibing2
pushed a commit
to luobosibing2/oh-my-opencode
that referenced
this pull request
Feb 23, 2026
…-yeongyu#309) Critical fixes: - Bug #1: SubagentStop hook defaulted all agents to 'failed' because SDK doesn't provide `success` field. Now defaults to 'completed' when undefined. - Bug code-yeongyu#4: Token stats lost across TokenTracker instances. Constructor now restores session stats from global state for the same session ID. - Bug code-yeongyu#5: Ultrawork session isolation bypassed when both session IDs were undefined (undefined === undefined). Now rejects all falsy session IDs. High priority fixes: - Bug code-yeongyu#6: Cancel skill force-clear missed 12+ state files (boulder, hud-state, subagent-tracking, checkpoints, etc). Added comprehensive list. - Bug code-yeongyu#7: HUD semverCompare() returned NaN on pre-release versions like "3.9.5-beta". Fixed to use parseInt and handle pre-release ordering. - Bug code-yeongyu#8: Silent JSON parse failures in critical state readers. Added error logging to ralph and ultrawork state readers. - Bug code-yeongyu#9: Stale task detection had no default behavior when onStaleSession callback was not configured. Now auto-cleans after 2x threshold. - Bug code-yeongyu#10: Hardcoded 3-architect assumption in validation. Extracted to REQUIRED_ARCHITECTS constant. Medium priority fixes: - Bug code-yeongyu#11: Auto-invoke history used non-atomic writes. Now uses atomicWriteJson to prevent corruption from concurrent sessions. - Bug code-yeongyu#12: Ecomode docs said "all tasks" use Haiku, contradicting the escalation paths. Clarified to "most tasks" with upgrade criteria. - Bug code-yeongyu#13: Added safeUnlinkSync/safeRmSync utilities to prevent ENOENT crashes during cleanup operations. - Bug code-yeongyu#14: State files containing user prompts written with 0644 permissions. Now writes with 0600 (owner-only read/write). - Bug code-yeongyu#15: Model names recorded inconsistently (e.g., 'claude-3-5-haiku' vs 'claude-haiku-4'). Now normalizes at recording time via exported normalizeModelName(). Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes segmentation fault during plugin initialization on Bun 1.3.5 + macOS 15 by deferring module-level side effects to first use.
SG_CLI_PATHconstant; usegetSgCliPath()lazily incheckEnvironment()setIntervalinsidecreateCommentCheckerHooks()with guard flagRoot Cause
The crash occurred during module evaluation when:
SG_CLI_PATH = getSgCliPath()ran at import timegetSgCliPath()→findSgCliPathSync()→createRequire(import.meta.url)createRequire()during module evaluation can trigger a segfaultChanges
Fix 1: Lazy AST-grep CLI Path Resolution
Fix 2: Deferred Timer Registration
Verification
bun run typecheck)bun test)bun run build)Oracle Analysis
Consulted 3 parallel oracle agents to verify no regressions:
Fixes #292