Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Cannot GET /bundle.js with browser production build #12962

Closed
perrinjerome opened this issue Sep 30, 2023 · 2 comments · Fixed by #12964
Closed

Cannot GET /bundle.js with browser production build #12962

perrinjerome opened this issue Sep 30, 2023 · 2 comments · Fixed by #12964
Labels
critical critical bugs / problems

Comments

@perrinjerome
Copy link
Contributor

Bug Description:

I have been using a theia browser application very similar to examples/browser, where unlike examples/browser which uses theia build in development mode (see below), I just used the theia build with default mode, which is production.

"bundle": "yarn rebuild && theia build --mode development",

It was working fine with theia 1.35.0 but when I tried to update to 1.42.0 I have an error when opening http://localhost:3000/ with the browser because /bundle.js serves an error page Cannot GET /bundle.js.

Steps to Reproduce:

After cloning theia repository:

yarn install
cd examples/browser/
yarn compile
npx theia clean  # make sure we are clean from previous builds
npx theia rebuild
npx theia build  # ( without --mode=production )
npx theia start
# test the application, this prints 200 on success, 404 on error
curl -s -o /dev/null -w "%{http_code}" http://localhost:3000/bundle.js

Additional Information

I have bisected that this comes from 45a0953 which seems unrelated, but maybe triggers something with webpack in production mode. I have no idea why this would happen, but when reverting part of this commit by applying this patch on top of master, bundle.js is generated again:

diff --git a/packages/core/src/browser/preload/theme-preload-contribution.ts b/packages/core/src/browser/preload/theme-preload-contribution.ts
index a8df24634..c275f72ec 100644
--- a/packages/core/src/browser/preload/theme-preload-contribution.ts
+++ b/packages/core/src/browser/preload/theme-preload-contribution.ts
@@ -17,14 +17,14 @@
 import { PreloadContribution } from './preloader';
 import { DEFAULT_BACKGROUND_COLOR_STORAGE_KEY } from '../frontend-application-config-provider';
 import { injectable } from 'inversify';
-import { DefaultTheme } from '@theia/application-package';
+// import { DefaultTheme } from '@theia/application-package';
 
 @injectable()
 export class ThemePreloadContribution implements PreloadContribution {
 
     initialize(): void {
         const dark = window.matchMedia?.('(prefers-color-scheme: dark)').matches;
-        const value = window.localStorage.getItem(DEFAULT_BACKGROUND_COLOR_STORAGE_KEY) || DefaultTheme.defaultBackgroundColor(dark);
+        const value = window.localStorage.getItem(DEFAULT_BACKGROUND_COLOR_STORAGE_KEY) || (dark ? '#1E1E1E' : '#FFFFFF');
         document.documentElement.style.setProperty('--theia-editor-background', value);
     }

I am not suggesting doing this change, just mentioning this in case it helps in tracking down the issue.

  • Operating System: linux
  • Theia Version: git master
@msujew
Copy link
Member

msujew commented Sep 30, 2023

@planger Can confirm, this is related to #12897. The @theia/application-package imports from nano which imports from node:url - which obviously doesn't load in a browser context. This also prevents the whole preload script from running, as it already fails during import time.

See #12964 for a fix.

@msujew msujew added the critical critical bugs / problems label Sep 30, 2023
@planger
Copy link
Contributor

planger commented Sep 30, 2023

Thanks @perrinjerome for raising this issue and thank you very much @msujew for the analysis and fix! I've tested and approved #12964.

planger added a commit to eclipsesource/theia that referenced this issue Sep 30, 2023
Currently we don't seem to have any automated test that verifies whether
the production build works as expected.

For a recent issue and its root cause, which remained unrevealed by the
CI, see
eclipse-theia#12962

Contributed on behalf of STMicroelectronics

Change-Id: Ia2fdb54873344e5d0da12522441a649b6b90bdac
planger added a commit that referenced this issue Nov 16, 2023
Currently we don't seem to have any automated test that verifies whether
the production build works as expected.

For a recent issue and its root cause, which remained unrevealed by the
CI, see #12962

Contributed on behalf of STMicroelectronics
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
critical critical bugs / problems
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants