Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

Sanity Codegen process hangs on completion #243

Open
alexbchr opened this issue Jan 16, 2022 · 1 comment · May be fixed by #246
Open

Sanity Codegen process hangs on completion #243

alexbchr opened this issue Jan 16, 2022 · 1 comment · May be fixed by #246

Comments

@alexbchr
Copy link
Contributor

We are currently starting a new project and realized that for some reason, running  sanity-codegen on the project using Node 16.13.2 (or 15.14.0) just hangs. This seems to be a very similar issue to #232.

What I did try locally to fix this is adding a then clause that explicitly exits the process at the end of the CLI process fixes the issue.

In cli.ts file, replacing:

cli().catch((e) => {
  console.error(e);
  process.exit(1);
});

With:

cli().then(() => process.exit(0)).catch((e) => {
  console.error(e);
  process.exit(1);
});

Fixed the hanging issue. Since the last line of cli() gets correctly printed on the culprit computer, the Promise ends fine and everything, but for some unknown reason the process just remains alive. Seems like something in the code is being kept alive that prevents Node from ending the process properly when its work is done. I have no idea what this would be though.

I was able to reproduce on many different computers this time, and even running sanity-codegen inside Github Actions hangs by using the same Node version.

Running sanity-codegen on Node 12 and 14 works fine without any issue.

@ricokahler
Copy link
Owner

If you wanted to open a PR that includes the process.exit, i'll accept it. This is something that next.js even does so i'm fine with including something similar.

@alexbchr alexbchr linked a pull request Jan 17, 2022 that will close this issue
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants