Repository navigation
fix: prevent silent CLI exits - #18398
Merged
Merged
Conversation
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
Contributor
📦 esbuild Bundle Analysis for payloadThis analysis was generated by esbuild-bundle-analyzer. 🤖
Largest pathsThese visualization shows top 20 largest paths in the bundle.Meta file: packages/next/meta_index.json, Out file: esbuild/index.js
Meta file: packages/payload/meta_index.json, Out file: esbuild/index.js
Meta file: packages/payload/meta_shared.json, Out file: esbuild/exports/shared.js
Meta file: packages/richtext-lexical/meta_client.json, Out file: esbuild/exports/client_optimized/index.js
Meta file: packages/ui/meta_client.json, Out file: esbuild/exports/client_optimized/index.js
Meta file: packages/ui/meta_shared.json, Out file: esbuild/exports/shared_optimized/index.js
DetailsNext to the size is how much the size has increased or decreased compared with the base branch of this PR.
|
AlessioGr
marked this pull request as draft
September 29, 2026 19:47
AlessioGr
marked this pull request as ready for review
September 29, 2026 23:18
AlessioGr
enabled auto-merge (squash)
September 29, 2026 23:18
GermanJablo
approved these changes
Sep 30, 2026
GermanJablo
left a comment
Contributor
There was a problem hiding this comment.
Discussed and reviewed in Slack
AlessioGr
added a commit
that referenced
this pull request
Sep 30, 2026
…18397) _Written with AI_ Upgrades `lexical` and every installed `@lexical/*` package from `0.50.0` to `0.52.0` for Payload 4.x (`main`), and pinned `tsx` dependencies from `4.22.4` to `4.23.15`. Removes the native-loader workaround no longer needed with the new tsx version. Also fixes duplicate image uploads triggered by repeated node transforms in Lexical 0.52. CI fixes update the keyboard-navigation expectation and correct an existing auth-test parameter error that blocked integration tests. Fixes #17757 3.x counterpart: #18398. ## Why this fixes the CLI failure With Payload 3.90.1 on Node 22.22.0, importing a config that included `lexicalEditor()` could leave CLI startup pending before the config or target script was evaluated. The process then exited 0 with no output and left a pending PostgreSQL migration unapplied. Previously, Payload started the CLI with `void start()`, and an unresolved promise alone does not keep Node's event loop alive. Lexical 0.50's Node entry points select their build with top-level `await import(...)`, which is probably what caused it. Lexical has shipped ESM-only packages since **0.51**, using static imports instead of those asynchronous Node wrappers. Upgrading to 0.52 fixes this issue. Also removes the `module.registerHooks = undefined` workaround for #16949. tsx 4.23.15 [excludes bare built-ins from namespace inheritance](privatenumber/tsx@38e1588), following its [Node 24 `tsImport` bridge fix](privatenumber/tsx@6e5236b). ## CLI exit codes CLI startup is now awaited at the top level in all three loader paths: tsx, SWC, and disabled transpilation. If an import never settles and Node runs out of work, Node reports an unsettled top-level await and exits 13. Successful commands still exit 0, and command-specific failure codes are preserved. ## Breaking changes Rich-text data keeps its existing format. No database migration is needed. Payload's built-in features have been updated, but your own TypeScript code or custom features may need changes: - **Generic types:** `SerializedEditorState<T>`, `SerializedElementNode<T>`, and `SerializedRootNode<T>` no longer accept `<T>`. Remove it if the base node type is enough, or use Payload's `TypedEditorState<T>` for documents with your own node types. Without `<T>`, children are still `SerializedLexicalNode[]`. - **Export types:** `ReturnType<Node['exportJSON']>` can now make fields such as `version` and `url` optional. Use the node's explicit serialized type, such as `SerializedLinkNode`, when you need the full format. Normal `node.exportJSON()` calls still return full JSON. - **Selection listeners:** `SELECTION_CHANGE_COMMAND` now fires before the DOM is updated. If your custom listener reads the DOM, defer that work with `$onUpdate(() => editor.read('latest', callback))`. - **Saved node references:** If you keep a node reference across an editor update, call `node.getLatest().exportJSON()` to export its current values. The type changes also affect imports through `@payloadcms/richtext-lexical/lexical` and its subpaths. Payload's `TypedEditorState<T>` and its own serialized node types keep their generic APIs for this upgrade. Keep importing Lexical through Payload's re-exports; do not install a separate Lexical version. See the [custom feature documentation](https://payloadcms.com/docs/rich-text/custom-features). The table below also lists removed APIs that may affect custom features. `LexicalComposer` is deprecated but still available. ## Breaking changes and Payload migrations Reviewed [0.51.0](https://github.com/facebook/lexical/releases/tag/v0.51.0) and [0.52.0](https://github.com/facebook/lexical/releases/tag/v0.52.0), including the serialization declarations. **Yes** means Payload code needed adaptation; **No** means no Payload migration was required. | Release | Breaking change | Required migration in Payload | Changes made | | ------- | --------------- | ----------------------------- | ------------ | | 0.51 | [npm packages are ESM only](meta/lexical#9127); older CommonJS consumers must use dynamic imports. | No | Payload already uses ESM. This removes the asynchronous Lexical wrapper involved in the CLI reproducer. | | 0.51 | [Serialization schemas and compact export](meta/lexical#8602) add `exportJSON` overloads and remove the `SerializedEditorState`, `SerializedElementNode`, and `SerializedRootNode` generics. `ReturnType` can now infer compact, partial JSON. | Yes | Infer the full-format overload for node hooks, validation and population while preserving custom nodes' literal `type` discriminants. Update `hasText` to the non-generic editor-state type. | | 0.51 | [`exportJSON` can serialize a retained instance without calling `getLatest()`](meta/lexical#8602). | No | Audited Payload's clipboard and Markdown call sites: they serialize nodes obtained from the current selection/tree, without an intervening mutation. Custom callers holding stale references should use `node.getLatest().exportJSON()`. | | 0.51 | [Deprecated Prism re-exports are removed from `@lexical/code`](meta/lexical#9141). | No | Payload does not consume the removed exports. | | 0.52 | [`SELECTION_CHANGE_COMMAND` runs before DOM reconciliation](meta/lexical#9219), including node and table selections. | Yes | Defer link popup, inline toolbar and decorator DOM work with `$onUpdate` and `editor.read('latest', ...)`. Keep nested decorator updates with their own editor. The table menu already defers DOM reads. | | 0.52 | [Default HTML export honors `DOMRenderExtension` `$createDOM` overrides](meta/lexical#9231). | No | Payload does not configure these extension overrides; existing converter tests pass. | | 0.52 | [`LexicalNode.getCommonAncestor` is removed](meta/lexical#9238). | No | No Payload call sites. Custom consumers can use `$getCommonAncestor`, accounting for its different handling of non-element nodes. | React package entry points were compared against 0.50.0; no Payload proxy exports need adding or removing. ## Previous Lexical upgrades - [#18149](#18149) — 0.48.0 → 0.50.0 - [#17554](#17554) — 0.45.0 → 0.48.0 - [#17064](#17064) — 0.41.0 → 0.45.0
Contributor
|
🚀 This is included in version v3.91.0 |
4 of 5 tasks
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.
Written with AI
Fixes #17757 and #18398 for Payload 3.x without upgrading Lexical. Existing commands such as
pnpm payload migrateandpnpm payload runwork without extra flags or configuration.Keeps Lexical at 0.50.0 and upgrades pinned tsx dependencies from 4.22.4 to 4.23.15 across the workspace and templates. The tsx upgrade also lets us remove the
module.registerHooks = undefinedworkaround for #16949.Why this fixes the CLI failure
In the reproducer on Node 22.22.0, loading a config with
lexicalEditor()could leave module evaluation pending before the config or target script ran. With no active work keeping the process alive, the CLI exited 0 without applying the migration. Updating tsx alone still reproduced the failure.Lexical 0.50's default Node entry points select their development or production build using top-level
await import(...). Its package exports also expose those same builds directly. Payload now registers an internal resolver before importing the config or script, selecting the matching static export forlexicaland@lexical/*. This avoids the asynchronous wrappers involved in the failure.The resolver reads
NODE_ENVafter loading.envfiles, preserves explicit development/production conditions, and leaves other packages' export conditions unchanged. It applies only when using the CLI.The resolver prefers
module.registerHooks()when available, following Node's recommendation, and keepsmodule.register()as the fallback on older Node versions. Both paths use the same resolver and initialize it after loading.envfiles. This avoids theDEP0205deprecation warning on Node 26. Verified with warnings enabled in an app installed from packed packages on Node 20, 22, and 26.Exit-code guard
If an import stalls and Node runs out of work before the CLI finishes, the command now exits with code 1 instead of reporting success. A
beforeExitguard covers startup and command execution, and is removed when the CLI completes. Successful commands and explicit command exit codes keep their existing behavior.tsx upgrade and workaround removal
The tsx bump separately fixes the native-loader problem behind #16949: it excludes bare built-ins from namespace inheritance, following the Node 24
tsImportbridge fix. CLI execution was verified on Node 22 and 24 with the old workaround removed.