Skip to content

perf(packaging): prune Linear SDK source maps after packaging - #17530

Merged
nwparker merged 2 commits into
stablyai:mainfrom
nwparker:nwparker/pr-size-linear-20260830
Aug 31, 2026
Merged

nwparker merged 2 commits into
stablyai:mainfrom
nwparker:nwparker/pr-size-linear-20260830

Conversation

@nwparker

Copy link
Copy Markdown
Contributor

What this changes

After electron-builder copies the runtime closure, remove only JavaScript source-map files under Resources/node_modules/@linear/sdk. Runtime CJS/ESM files, package metadata, exports, webhooks, and non-JavaScript maps remain untouched.

ELI5

Source maps are debugger notes, not code the app runs. The Linear SDK ships several megabytes of those notes. This PR removes only those notes after packaging, leaving the executable SDK files in place.

Measurement (macOS arm64, unpacked dist/mac-arm64/Orca.app)

  • Removed exactly 6,834,529 bytes (6.52 MiB) of SDK JavaScript maps.
  • The packaged SDK is 5,212,253 bytes across 11 files with zero remaining .js.map, .cjs.map, or .mjs.map files.
  • Removed files were index.mjs.map (6,819,500 B) and webhooks-Bbhy0Mv8.mjs.map (15,029 B).

Crash-report/debugability

The app’s own crash reports are unchanged. This package-level cleanup can only affect opt-in source-map remapping for Linear SDK frames; normal CJS execution and the existing errorStack, componentStack, breadcrumb, and minidump paths do not load these files. The test preserves runtime CJS/ESM exports and explicitly leaves unrelated/non-JavaScript maps intact.

Readiness checklist

Reviewed against all eight sections:

  • SSH/remote/network: no SSH, relay, RPC, or network code changed.
  • Crash/retry/growth: bounded build-time walk of one fixed package; no runtime retry/state/cache growth.
  • Security/supply chain: no dependency versions, install hooks, secrets, or network behavior changed.
  • Performance/resources: one post-pack cleanup walk; no runtime cost; measured 6.52 MiB reduction.
  • Functional correctness: CJS SDK, CJS webhooks, ESM entrypoints, and metadata/exports were load-tested after pruning.
  • Backward compatibility/data loss: no persisted state, schema, IPC, mobile, or wire contract touched.
  • Cross-platform/remoting: uses path.join; cleanup is target-independent and stays inside the packaged runtime closure.
  • Code organization: pruning lives alongside the existing packaged-runtime cleanup functions.

Verdict: PASS. No proven P0/P1/P2 findings. Residual risk is limited to source-map remapping for opt-in SDK debugging.

Validation

  • Focused SDK-prune tests passed, including aggregate cleanup coverage.
  • CJS and ESM runtime/export checks passed after pruning.
  • pnpm run tc:node, changed-file lint/format checks, and git diff --check passed.

@greptile-apps

greptile-apps Bot commented Aug 31, 2026 •

Copy link
Copy Markdown

Greptile Summary

The PR reduces packaged application size by removing JavaScript source maps specifically from the packaged @linear/sdk dependency after Electron copies the runtime closure.

  • Adds a package-scoped Linear SDK source-map cleanup step to aggregate runtime pruning.
  • Adds focused and aggregate tests covering map removal, runtime exports, metadata, and unrelated artifacts.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
config/packaged-runtime-node-modules.cjs Adds a narrowly scoped post-packaging cleanup that removes .js.map, .cjs.map, and .mjs.map files beneath the packaged Linear SDK.
config/scripts/packaged-linear-sdk-prune.test.mjs Verifies direct and aggregate pruning while preserving SDK runtime exports, package metadata, non-JavaScript maps, and unrelated packages.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Electron afterPack] --> B[Aggregate runtime cleanup]
  B --> C[Locate packaged @linear/sdk]
  C --> D{Package exists?}
  D -- No --> E[Return]
  D -- Yes --> F[Walk package files]
  F --> G{JavaScript source map?}
  G -- Yes --> H[Remove file]
  G -- No --> I[Preserve file]
Loading

Reviews (2): Last reviewed commit: "Merge branch 'main' into nwparker/pr-siz..." | Re-trigger Greptile

@coderabbitai

coderabbitai Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 76bbb577-9c86-4ef8-89e4-b7a97ec3c86a

📥 Commits

Reviewing files that changed from the base of the PR and between a0d36f5 and 6dbd4d8.

📒 Files selected for processing (2)
  • config/packaged-runtime-node-modules.cjs
  • config/scripts/packaged-linear-sdk-prune.test.mjs

Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

The packaging module adds prunePackagedLinearSdkSourceMaps to remove .js.map files from @linear/sdk. The function runs as part of aggregate runtime module pruning and is exported. New tests create a package fixture, verify source-map removal and runtime-file preservation, confirm unrelated packages remain unchanged, test SDK loading, and cover aggregate cleanup.

Merge Risk: ⚪ Minimal · up to 6dbd4

The package keeps all executable Linear SDK files and metadata while removing only unused JavaScript source maps from newly built application artifacts, reducing package size without changing runtime behavior. No actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the change, purpose, impact, measurements, risks, and validation. However, it omits several required template sections, including the linked issue, visual proof or an explicit… Add the required template sections. Include a linked issue under "Linked Issue" using "Fixes #..."; add "N/A" with a reason under "Visual Proof"; complete or explicitly address AI Disclosure, Review, Agent skill upstream boundary, and Check…
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the packaging change and the removal of Linear SDK source maps.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description explains the change, purpose, impact, measurements, risks, and validation. However, it omits several required template sections, including the linked issue, visual proof or an explicit N/A statement, AI disclosure, review, agent skill upstream boundary, and checklist items.

Resolution

Add the required template sections. Include a linked issue under "Linked Issue" using "Fixes #..."; add "N/A" with a reason under "Visual Proof"; complete or explicitly address AI Disclosure, Review, Agent skill upstream boundary, and Checklist sections; and use the required "Testing" section to list automated and manual test coverage and platforms tested.

  • Fix all pre-merge checks with AI

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nwparker

Copy link
Copy Markdown
Contributor Author

Readiness checklist review — PASS

Reviewed all 8 sections. No proven P0/P1/P2 findings.

  • Crash/debugability: app crash fields and breadcrumbs are unchanged. Only opt-in source-map remapping for Linear SDK frames is affected; normal CJS/ESM execution does not load the removed maps.
  • SSH/mobile/remoting/data: no SSH, relay, RPC, persisted-state, schema, or mobile-facing surface changed.
  • Security: no dependency versions, install hooks, secrets, or network behavior changed.
  • Performance/resources: bounded post-pack cleanup removes exactly 6,834,529 bytes (6.52 MiB); no runtime cost.
  • Functional/cross-platform: CJS SDK, CJS webhooks, ESM entries, exports, metadata, and unrelated maps remain loadable/present; path.join keeps the cleanup portable.
  • Organization: cleanup is colocated with existing packaged-runtime pruning.

ELI5: delete debugger notes the app never reads, keep the executable SDK code and package labels.

@pullfrog pullfrog 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 new issues found.

Reviewed changes

  • Linear SDK source-map prune — config/packaged-runtime-node-modules.cjs adds prunePackagedLinearSdkSourceMaps, which recursively removes .js / .cjs / .mjs source maps under node_modules/@linear/sdk, wires it into prunePackagedRuntimeNodeModules (the electron-builder afterPack step), and exports it for tests.
  • Focused test coverage — config/scripts/packaged-linear-sdk-prune.test.mjs builds a realistic SDK fixture (CJS/ESM entries, webhooks, a non-JS .json.map, and an unrelated package's map) and asserts exact post-prune directory contents plus a runtime require('@linear/sdk') load check; a second case exercises the full aggregate cleanup path.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@nwparker

Copy link
Copy Markdown
Contributor Author

CI status note

All eight test shards, typecheck, package, package (Windows), guards, and both automated code reviews pass. The remaining static-analysis failure is the unchanged baseline src/main/runtime/rpc/dispatcher.ts:323 max-lines error (302 counted lines); verify fails only because it requires static analysis success. Neither failing check implicates this PRs two changed packaging/test files.

@nwparker
nwparker merged commit 9f0b94d into stablyai:main Aug 31, 2026
53 of 55 checks passed
nwparker added a commit that referenced this pull request Aug 31, 2026
…17641)

`serializes FETCH_HEAD callers before they enter admission` assumed that two
same-repo fetches join the FETCH_HEAD lock lane in call order. They do not.

`runWithGitFetchHeadLock` first `await`s `fetchLockPath`, which walks the
filesystem (`realpath`, `stat` per parent directory, `readFile` of `commondir`,
`realpath` again) before it calls `runWithGitOperationLock`, and the lane is
registered only after that walk resolves. For a non-existent `/repo` that is
five libuv threadpool round-trips per caller. Two callers issued back to back
run their chains concurrently, so lane order is threadpool completion order,
not call order.

When the `interactive` fetch won that race it entered the lane ahead of the
`background` fetch. On the first caller's release it reached admission
immediately and, being interactive, took the free network headroom slot instead
of queueing, while the background fetch stayed parked on the lock. `queued`
therefore settled at 0 and never reached the asserted 1. Measured inversion
rate for the bare lock-path walk was 54/500 on an idle machine; the test itself
failed 5/20 locally, always at the same assertion, matching the two CI failures
on unrelated PRs (#17530, #17630) at the same line.

Fix the premise rather than the symptom: stub only the key derivation, keeping
the real FIFO `runWithGitOperationLock` that the test actually exercises, so the
lane is registered synchronously with the call. Key derivation keeps its own
coverage in `src/shared/git-fetch-head-lock.test.ts`. This also stops the fetch
tests in this file from sharing one global `/.git/FETCH_HEAD` lane with each
other and from touching the real filesystem.

Verified deterministic: 40/40, then 30/30 clean runs, plus 25/25 with twelve CPU
hogs and a concurrent `src/main/git/command-runner/` run saturating the box.
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…tablyai#17641)

`serializes FETCH_HEAD callers before they enter admission` assumed that two
same-repo fetches join the FETCH_HEAD lock lane in call order. They do not.

`runWithGitFetchHeadLock` first `await`s `fetchLockPath`, which walks the
filesystem (`realpath`, `stat` per parent directory, `readFile` of `commondir`,
`realpath` again) before it calls `runWithGitOperationLock`, and the lane is
registered only after that walk resolves. For a non-existent `/repo` that is
five libuv threadpool round-trips per caller. Two callers issued back to back
run their chains concurrently, so lane order is threadpool completion order,
not call order.

When the `interactive` fetch won that race it entered the lane ahead of the
`background` fetch. On the first caller's release it reached admission
immediately and, being interactive, took the free network headroom slot instead
of queueing, while the background fetch stayed parked on the lock. `queued`
therefore settled at 0 and never reached the asserted 1. Measured inversion
rate for the bare lock-path walk was 54/500 on an idle machine; the test itself
failed 5/20 locally, always at the same assertion, matching the two CI failures
on unrelated PRs (stablyai#17530, stablyai#17630) at the same line.

Fix the premise rather than the symptom: stub only the key derivation, keeping
the real FIFO `runWithGitOperationLock` that the test actually exercises, so the
lane is registered synchronously with the call. Key derivation keeps its own
coverage in `src/shared/git-fetch-head-lock.test.ts`. This also stops the fetch
tests in this file from sharing one global `/.git/FETCH_HEAD` lane with each
other and from touching the real filesystem.

Verified deterministic: 40/40, then 30/30 clean runs, plus 25/25 with twelve CPU
hogs and a concurrent `src/main/git/command-runner/` run saturating the box.
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.

1 participant