Commit 6bd2768
committed
RBAC tests: extract projectCreated to break platform.v3.server cycle (TRI-8731)
After rebasing rbac-packages on origin/main, the e2e.full harness
regressed with the same `TypeError: Cannot convert undefined or null
to object at allMachines (build/index.js:71862)` that TRI-8731
worked around by switching the testcontainer to NODE_ENV=production.
Recent main commits changed the bundled init order enough that the
production-mode dodge no longer applies — the cycle now triggers in
both NODE_ENV=test and NODE_ENV=production.
Root cause is structural:
app/services/platform.v3.server → imports createEnvironment
from app/models/organization.server
app/models/organization.server → imports getDefaultEnvironmentConcurrencyLimit
from app/services/platform.v3.server
Inside an esbuild __esm bundle, this manifests as:
init_platform_v3_server() runs init_organization_server() in the
middle of its body. organization.server's body re-enters
init_platform_v3_server(), which short-circuits because the outer
call already cleared its `fn` — so `({ defaultMachine, machines } =
singleton("machinePresets", ...))` never completes its destructure
and both vars stay undefined. Object.entries(undefined) crashes
when `allMachines()` runs inside `createRunEngine()`.
Fix: move the only function in platform.v3.server.ts that imports
from organization.server (`projectCreated`, the sole caller of
`createEnvironment`) into its own file. platform.v3.server.ts no
longer imports from organization.server, so the cycle is gone. Two
trivial supporting changes:
- export `isCloud` from platform.v3.server (projectCreated needs it)
- drop the now-unused `Organization` and `Project` type imports
No dynamic imports, no application-code workarounds — just a
structural file split.
Verified:
- 162/162 e2e.full pass (auth-api, auth-cross-cutting, auth-dashboard)
- 31/31 api-auth.e2e pass
- 31/31 @trigger.dev/rbac unit tests pass
- 7/7 cloud enterprise e2e.full pass against the same webapp build1 parent 0b7eaa6 commit 6bd2768
4 files changed
Lines changed: 120 additions & 48 deletions
File tree
- apps/webapp/app
- models
- services
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
29 | 28 | | |
30 | 29 | | |
31 | 30 | | |
| |||
569 | 568 | | |
570 | 569 | | |
571 | 570 | | |
572 | | - | |
573 | | - | |
574 | | - | |
575 | | - | |
576 | | - | |
577 | | - | |
578 | | - | |
579 | | - | |
580 | | - | |
581 | | - | |
582 | | - | |
583 | | - | |
584 | | - | |
585 | | - | |
586 | | - | |
587 | | - | |
588 | | - | |
589 | | - | |
590 | | - | |
591 | | - | |
592 | | - | |
593 | | - | |
594 | | - | |
595 | | - | |
596 | | - | |
597 | | - | |
598 | | - | |
599 | 571 | | |
600 | 572 | | |
601 | 573 | | |
| |||
770 | 742 | | |
771 | 743 | | |
772 | 744 | | |
773 | | - | |
| 745 | + | |
774 | 746 | | |
775 | 747 | | |
776 | 748 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments