Skip to content

[fix]: resolve supervisor.js via import.meta.url#1702

Merged
seanmcguire12 merged 1 commit into
mainfrom
fix-supervisor-js-missing
Feb 18, 2026
Merged

[fix]: resolve supervisor.js via import.meta.url#1702
seanmcguire12 merged 1 commit into
mainfrom
fix-supervisor-js-missing

Conversation

@seanmcguire12

@seanmcguire12 seanmcguire12 commented Feb 18, 2026

Copy link
Copy Markdown
Member

why

  • the supervisorClient was unable to find the supervisor.js file after we migrated to esm
  • the old code preferred __dirname over import.meta.url, but tsx polyfills __dirname in esm mode and it can resolve to the wrong directory

what changed

  • use import.meta.url instead of __dirname

Summary by cubic

Fixes supervisor script resolution in ESM by using import.meta.url, preventing failures when __dirname is polyfilled by tsx.

  • Bug Fixes
    • Resolve supervisor.js using import.meta.url instead of __dirname.
    • Improve missing-script error message to include the searched directory.

Written for commit 42c84bd. Summary will update on new commits. Review in cubic

@changeset-bot

changeset-bot Bot commented Feb 18, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 42c84bd

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

@greptile-apps

greptile-apps Bot commented Feb 18, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Fixes the shutdown supervisor script resolution in ESM mode by removing the __dirname fallback and using import.meta.url exclusively.

  • Removed the typeof __dirname === "string" conditional that preferred __dirname over import.meta.url. The tsx loader polyfills __dirname in ESM mode, which resolved to the wrong directory and caused supervisor.js to not be found.
  • Improved the error message in ShutdownSupervisorResolveError to include the actual searched directory (thisDir), making it easier to debug resolution failures.
  • The CJS build is unaffected because esbuild converts import.meta.url into the equivalent CJS construct when bundling in CJS format.

Confidence Score: 5/5

  • This PR is safe to merge — it's a targeted fix with no behavioral change beyond correcting path resolution.
  • The change is minimal (removing an incorrect fallback), addresses a confirmed bug, and the remaining import.meta.url approach is the standard ESM solution. The CJS build is unaffected due to esbuild's automatic transformation. The improved error message is a non-breaking improvement.
  • No files require special attention.

Important Files Changed

Filename Overview
packages/core/lib/v3/shutdown/supervisorClient.ts Replaces __dirname fallback with direct import.meta.url for resolving supervisor.js path. Fixes ESM resolution issue caused by tsx polyfilling __dirname to the wrong directory. Also improves error message to include the searched directory for easier debugging.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["supervisorClient.ts<br/>startShutdownSupervisor()"] --> B["Resolve thisDir via<br/>import.meta.url"]
    B --> C["resolveSupervisorScript()"]
    C --> D{"supervisor.js exists<br/>in thisDir?"}
    D -- Yes --> E["Spawn node supervisor.js"]
    D -- No --> F{"supervisor.ts exists<br/>in thisDir?"}
    F -- Yes --> G["Spawn node --import tsx supervisor.ts"]
    F -- No --> H["ShutdownSupervisorResolveError<br/>(includes searched dir)"]
    E --> I["IPC: send config"]
    G --> I
    I --> J["Wait for 'ready' or timeout"]
Loading

Last reviewed commit: 42c84bd

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

@seanmcguire12
seanmcguire12 merged commit 04da404 into main Feb 18, 2026
146 of 147 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants