Repository navigation
fix(desktop): keep dbus-next external so Linux Wayland launches stop exiting #11856
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| import { assert, describe, it } from "@effect/vitest"; | ||
|
|
||
| import { | ||
| findInlinedDesktopExternalPackages, | ||
| isDesktopRuntimeExternalDependency, | ||
| selectDesktopRuntimeExternalDependencies, | ||
| } from "./desktop-external-packages.ts"; | ||
|
|
||
| describe("isDesktopRuntimeExternalDependency", () => { | ||
| it("bundles ordinary runtime dependencies", () => { | ||
| for (const id of ["effect", "@effect/platform", "electron-store"]) { | ||
| assert.strictEqual(isDesktopRuntimeExternalDependency(id), false, id); | ||
| } | ||
| }); | ||
|
|
||
| it("leaves native addons and their dlopen wrappers external", () => { | ||
| for (const id of [ | ||
| "@napi-rs/keyring", | ||
| "@crowecawcaw/xa11y", | ||
| "@clerk/electron-passkeys", | ||
| "ffi-rs", | ||
| "@yuuang/ffi-rs-win32-x64-msvc", | ||
| "playwright-core", | ||
| ]) { | ||
| assert.strictEqual(isDesktopRuntimeExternalDependency(id), true, id); | ||
| } | ||
| }); | ||
|
|
||
| // Regression test for #11720: an inlined dbus-next makes the lazy | ||
| // PortalCaptureShortcut/NiriCaptureShortcut chunk require("./main.cjs"), | ||
| // which re-evaluates top-level runMain after Electron is ready and exits | ||
| // every Linux Wayland launch with `registerSchemesAsPrivileged` throwing. | ||
| it("leaves dbus-next external, including subpath imports", () => { | ||
| for (const id of ["dbus-next", "dbus-next/lib/bus"]) { | ||
| assert.strictEqual(isDesktopRuntimeExternalDependency(id), true, id); | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| describe("selectDesktopRuntimeExternalDependencies", () => { | ||
| it("keeps only runtime-external dependency roots for the stage", () => { | ||
| assert.deepStrictEqual( | ||
| selectDesktopRuntimeExternalDependencies({ | ||
| "dbus-next": "0.10.2", | ||
| effect: "3.0.0", | ||
| "@napi-rs/keyring": "1.3.0", | ||
| "playwright-core": "1.60.0", | ||
| }), | ||
| { | ||
| "dbus-next": "0.10.2", | ||
| "@napi-rs/keyring": "1.3.0", | ||
| "playwright-core": "1.60.0", | ||
| }, | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
| // Configuring the bundler is not the same as checking what it emitted. These | ||
| // exercise the scanner against the marker shape rolldown actually produces. | ||
| describe("findInlinedDesktopExternalPackages", () => { | ||
| const region = (path: string) => `//#region ${path} | ||
| var x = 1; | ||
| //#endregion | ||
| `; | ||
|
|
||
| it("flags an inlined dbus-next", () => { | ||
| const source = | ||
| region("../../node_modules/.pnpm/dbus-next@0.10.2/node_modules/dbus-next/lib/bus.js") + | ||
| region("../../node_modules/.pnpm/effect@4.0.0/node_modules/effect/dist/index.js"); | ||
| const result = findInlinedDesktopExternalPackages(source); | ||
|
|
||
| assert.deepStrictEqual(result.inlined, ["dbus-next"]); | ||
| assert.strictEqual(result.regionCount, 2); | ||
| }); | ||
|
|
||
| it("ignores packages that are meant to be bundled", () => { | ||
| const source = | ||
| region("../../node_modules/.pnpm/effect@4.0.0/node_modules/effect/dist/index.js") + | ||
| region("../../apps/desktop/src/main.ts"); | ||
| const result = findInlinedDesktopExternalPackages(source); | ||
|
|
||
| assert.deepStrictEqual(result.inlined, []); | ||
| assert.strictEqual(result.regionCount, 2); | ||
| }); | ||
|
|
||
| // regionCount is what separates "clean" from "this scan went blind because the | ||
| // marker format changed". A caller that ignores it gets a vacuous pass. | ||
| it("reports the packages that were inlined, not just the violations", () => { | ||
| const source = | ||
| region("../../node_modules/.pnpm/effect@4.0.0/node_modules/effect/dist/index.js") + | ||
| region("../../node_modules/.pnpm/sax@1.4.1/node_modules/sax/lib/sax.js"); | ||
| const result = findInlinedDesktopExternalPackages(source); | ||
|
|
||
| assert.deepStrictEqual(result.inlinedPackages, ["effect", "sax"]); | ||
| assert.deepStrictEqual(result.inlined, []); | ||
| }); | ||
|
|
||
| it("reports no regions when the marker format is absent", () => { | ||
| const result = findInlinedDesktopExternalPackages( | ||
| "var x = 1; // node_modules/dbus-next/lib.js", | ||
| ); | ||
| assert.strictEqual(result.regionCount, 0); | ||
| assert.deepStrictEqual(result.inlined, []); | ||
| }); | ||
| }); |
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Medium
scripts/build-desktop-artifact.ts:3530The assertion skips
.cjsbundles in subdirectories, so an inline desktop-runtime external in workers such aselectron/WindowsForegroundFocusWorker.cjsorsnapShot/*.cjspasses validation and a broken packaged worker can ship.fs.readDirectory(distDirs.desktopDist)only returns direct entries; traversedist-electronrecursively or otherwise scan every emitted bundle file.🤖 Copy this AI Prompt to have your agent fix this: