Skip to content
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

server components (even dynamic) runs on build unexpectedly (through unstable_collectClientModules) #543

Open
himself65 opened this issue Feb 27, 2024 · 13 comments

Comments

@himself65
Copy link
Contributor

See: himself65@5e8218f

/Users/himself65/Library/Caches/fnm_multishells/48575_1709013514281/bin/pnpm run build

> waku-starter@0.1.0 build /Users/himself65/Code/waku/examples/01_template
> DONT_LEAK_IN_BUILD_TIME=NO waku build

vite v5.1.4 building SSR bundle for production...
✓ 42 modules transformed.
✓ built in 374ms
vite v5.1.4 building SSR bundle for production...
✓ 43 modules transformed.
dist/assets/root-layout-BDx5PYJp.css              11.64 kB
dist/assets/rsc1-ddb75831a.js                      0.15 kB
dist/components/header.js                          0.45 kB
dist/components/counter.js                         0.48 kB
dist/components/error-boundary.js                  0.51 kB
dist/templates/contact-page.js                     0.53 kB
dist/components/footer.js                          0.71 kB
dist/templates/about-page.js                       1.06 kB
dist/templates/root-layout.js                      1.16 kB
dist/templates/home-page.js                        1.16 kB
dist/assets/jsx-runtime.react-server-DaQipseb.js   1.25 kB
dist/assets/rsc2-19056431e.js                      1.99 kB
dist/assets/rsc0-1f451937d.js                      2.67 kB
dist/assets/react.react-server-BRc6Y66K.js        10.76 kB
dist/entries.js                                   12.98 kB
dist/rsdw-server.js                               41.09 kB
✓ built in 106ms
vite v5.1.4 building for production...
✓ 40 modules transformed.
dist/public/index.html                        1.01 kB │ gzip:  0.45 kB
dist/public/assets/rsc0-1f451937d.js          0.21 kB │ gzip:  0.17 kB
dist/public/assets/rsc1-ddb75831a.js          0.42 kB │ gzip:  0.31 kB
dist/public/assets/jsx-runtime-CcapePxT.js    0.63 kB │ gzip:  0.42 kB
dist/public/assets/main-A3kPowAf.js           0.73 kB │ gzip:  0.46 kB
dist/public/assets/indexHtml-DVWfb-0O.js      0.86 kB │ gzip:  0.49 kB
dist/public/assets/rsc2-19056431e.js          4.24 kB │ gzip:  1.80 kB
dist/public/assets/index-XTTFb40S.js          8.09 kB │ gzip:  3.06 kB
dist/public/assets/client-C95rG-dh.js       191.17 kB │ gzip: 60.21 kB
✓ built in 303ms
Error: SHOULD NOT LEAK
    at ContactPage (file:///Users/himself65/Code/waku/examples/01_template/dist/templates/contact-page.js:9:11)
    at ib (file:///Users/himself65/Code/waku/examples/01_template/dist/rsdw-server.js:573:7)
    at jb (file:///Users/himself65/Code/waku/examples/01_template/dist/rsdw-server.js:592:46)
    at Q (file:///Users/himself65/Code/waku/examples/01_template/dist/rsdw-server.js:711:16)
    at Object.toJSON (file:///Users/himself65/Code/waku/examples/01_template/dist/rsdw-server.js:629:15)
    at stringify (<anonymous>)
    at nb (file:///Users/himself65/Code/waku/examples/01_template/dist/rsdw-server.js:831:53)
    at kb (file:///Users/himself65/Code/waku/examples/01_template/dist/rsdw-server.js:859:7)
    at Timeout._onTimeout (file:///Users/himself65/Code/waku/examples/01_template/dist/rsdw-server.js:896:12)
    at listOnTimeout (node:internal/timers:573:17)

Process finished with exit code 0

Also exit code shouldn't be 0

@dai-shi
Copy link
Owner

dai-shi commented Feb 27, 2024

Thanks for opening up an issue.
Yeah, it seems like a bug. Can you dig into it?
exit status 0 is also weird.

@dai-shi dai-shi added the bug Something isn't working label Feb 27, 2024
@himself65
Copy link
Contributor Author

exit status 0 is also weird.

Working on this

@himself65
Copy link
Contributor Author

Working on this

@dai-shi
Copy link
Owner

dai-shi commented Feb 28, 2024

From what I understand #536 (comment), dist/public/index.html isn't created if / is not isStatic. So, I don't see how this happens. Hope you find a bug somewhere.

@himself65
Copy link
Contributor Author

inside unstable_collectClientModules

@dai-shi
Copy link
Owner

dai-shi commented Mar 6, 2024

From #573, what I'd say is it's not SSR (html generation) and it's a false positive (not leaking). So, I don't consider it's a bug per se.
However, I agree it's not a desirable behavior and I wish we could come up with a different solution and eliminate unstable_.

@dai-shi dai-shi removed the bug Something isn't working label Mar 6, 2024
@dai-shi
Copy link
Owner

dai-shi commented Mar 6, 2024

btw, do you have a real issue with the current non-ideal behavior?

@himself65
Copy link
Contributor Author

btw, do you have a real issue with the current non-ideal behavior?

Yeah, I will use getEnv in the runtime, there's no env var during my build time

@dai-shi
Copy link
Owner

dai-shi commented Mar 6, 2024

I see. It's unfortunate, but the current workaround would be add a check if such an env var is available or not (and do some fallback that would never be required in the runtime.)

@dai-shi dai-shi changed the title bug: index page will be always SSR server components (even dynamic) runs on build unexpectedly (through unstable_collectClientModules) Mar 10, 2024
@dai-shi
Copy link
Owner

dai-shi commented Apr 25, 2024

Current status: #573 (comment)

@dai-shi
Copy link
Owner

dai-shi commented Oct 13, 2024

Can we statically analyze the code?

I was just thinking about it. Analyzing statically is not possible with current architecture. defineRouter & createPages are designed to isolated from filesystem.

@himself65
Copy link
Contributor Author

I hope there's a enviroment like WAKU_STAGE === 'build' or globalThis.cleanup(fn) to make sure I can disconenct the database or ignore some SSR

@dai-shi
Copy link
Owner

dai-shi commented Oct 26, 2024

Try unstable_getPlatformObject for now.

unstable_phase?:
| 'analyzeEntries'
| 'buildServerBundle'
| 'buildSsrBundle'
| 'buildClientBundle'
| 'buildDeploy';

We might be missing something for emit....

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 a pull request may close this issue.

2 participants