chore(server): switch jest transform to @swc/jest#2948
Merged
Conversation
…eps SWC-safe ts-jest kept a full TypeScript program per worker, so workers were slow to tear down under CI load and intermittently logged "A worker process has failed to exit gracefully". @swc/jest is transpile-only: the server suite drops from ~66s to ~13s and workers exit cleanly with no warning. SWC's stricter CommonJS live-binding exports turn the codebase's existing circular dependencies into TDZ ReferenceErrors at module load, so this makes those cycles SWC-safe without changing runtime behaviour: - Wrap singular concrete TypeORM relation property types in `Relation<>` so emitted `design:type` metadata no longer eagerly references the related entity class. - Annotate forwardRef-injected constructor params with type-only import aliases so `design:paramtypes` doesn't eagerly reference the class; the value import stays for the forwardRef arrow. DI tokens are unchanged. - Give the media-server factory's three adapter injections explicit `@Inject(forwardRef(...))` (matching the sibling params) so their types can be aliased as well. Closes #2946
Collaborator
Author
|
@SmolSoftBoi Does this make sense? Ran into this several times already. Tests that times out, going slow and whatnot - after this they are not. Please look through it here, and tell me what you think. 👍 |
Collaborator
Author
|
@SmolSoftBoi Decided to merge, it's a good improvement, and I will follow up with a larger PR refactor later. |
Contributor
|
🎉 This PR is included in version 3.12.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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.
Closes #2946.
Replaces the server's
ts-jesttransform with@swc/jest(transpile-only). The server suite drops from ~66s to ~13s and workers exit cleanly — the intermittent "A worker process has failed to exit gracefully" warning is gone (it was slow ts-jest worker teardown under load, not a real handle leak).SWC's stricter CommonJS live-binding exports turn the existing circular dependencies into TDZ
ReferenceErrors at module load, so this also makes those cycles SWC-safe with no runtime change:Relation<>(TypeORM's documented fix) sodesign:typeno longer eagerly references the related entity.forwardRef-injected constructor params annotated via type-only import aliases sodesign:paramtypesdoesn't eagerly reference the class; the value import remains for theforwardRefarrow.@Inject(forwardRef(...))(matching the two sibling params) so their types can be aliased too.DI tokens/wiring are unchanged. Type-checking still runs via
nest buildin CI. The only behavioural change is to the test transformer.Note: this adds
@Inject(forwardRef(...))to the factory's adapter params — worth a quick boot smoke-test of the running server in addition to the green unit suite, since unit tests mock DI.