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

[Bug]: github工作流中yarnbuild 会完成打包但是无法自动退出命令行 #6162

Open
katocrane opened this issue Sep 3, 2024 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@katocrane
Copy link

Version

System:
    OS: macOS 13.6.4
    CPU: (8) arm64 Apple M2
    Memory: 118.34 MB / 8.00 GB
    Shell: 5.9 - /bin/zsh
  Browsers:
    Chrome: 128.0.6613.114
    Safari: 16.6
  npmPackages:
    @modern-js/app-tools: 2.58.2 => 2.58.2 
    @modern-js/eslint-config: 2.58.2 => 2.58.2 
    @modern-js/runtime: 2.58.2 => 2.58.2 
    @modern-js/tsconfig: 2.58.2 => 2.58.2

Details

本地打包似乎是每次modern.config.ts更改过后进行yarnbuild,就会出现日志已经说明打包完成但是不退出命令行的情况;生产环境的workflow会永远无法退出命令行导致工作流卡住
Uploading screenshot-20240903-161933.png…
image

Reproduce link

https://gist.github.com/katocrane/059c64273aa175407b9d99bc01a144ee

Reproduce Steps

执行yarn build

@katocrane katocrane added the bug Something isn't working label Sep 3, 2024
@botagar
Copy link

botagar commented Sep 6, 2024

I had the same issue with with pnpm build.
I switched to to using rspack as the bundler and it fixed this hanging problem.
Seems like it's an issue with the Webpack integration?

In modern.config.js

appTools({
  bundler: 'rspack',
}),

@chenjiahan
Copy link
Member

Try this package to find the root cause: https://www.npmjs.com/package/why-is-node-running

@katocrane
Copy link
Author

why-is-node-runningI tried to use this library but it didn't compile into modern.js successfully. Do you have any good code snippets for reference?

@chenjiahan
Copy link
Member

You can use it in the edenx.config.ts file

@katocrane
Copy link
Author

` tools: {
styledComponents: false,

webpack: config => {
  // 确保 config.plugins 已被定义
  config.plugins = config.plugins || [];

  // 添加自定义 DonePlugin 插件 在生产环境下保证打包后退出终端命令
  if (process.env.NODE_ENV === 'production') {
    config.plugins.push({
      apply: compiler => {
        compiler.hooks.done.tap('DonePlugin', () => {
          setTimeout(() => {
            console.log('✨ Build completed. Exiting process.');
            whyIsNodeRunning();
            // process.exit(0); // 构建完成后强制退出
          });
        });
      },
    });
  }
},

},`

`> yarn build
yarn run v1.22.22
warning package.json: No license field
$ modern build
Modern.js Framework v2.58.2

info Starting production build...
info Type checker is enabled. It may take some time.
ready Compiled in 18.7 s (web)
✨ Build completed. Exiting process.
There are 62 handle(s) keeping the process running.

FILEHANDLE

(unknown stack trace)

FILEHANDLE

(unknown stack trace)

FILEHANDLE

(unknown stack trace)

FILEHANDLE

(unknown stack trace)
error TypeError: Cannot read properties of null (reading 'startsWith')
at /Users/mac/Documents/youjiaassessmanage/node_modules/.cache/bundle-require/modern.config.PENeOo51.cjs:66:77
at Array.filter ()
at printStacks (/Users/mac/Documents/youjiaassessmanage/node_modules/.cache/bundle-require/modern.config.PENeOo51.cjs:66:39)
at whyIsNodeRunning (/Users/mac/Documents/youjiaassessmanage/node_modules/.cache/bundle-require/modern.config.PENeOo51.cjs:62:5)
at Timeout._onTimeout (/Users/mac/Documents/youjiaassessmanage/node_modules/.cache/bundle-require/modern.config.PENeOo51.cjs:153:17)
at listOnTimeout (node:internal/timers:573:17)
at processTimers (node:internal/timers:514:7)
◯ web ━━━━━━━━━━━━━━━━━━━━━━━━━ 99% done
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.`

As you can see, I have already integrated it, but it seems to have a problem. I have done a series of troubleshooting but it has not been solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants