Skip to content

Unhandled promise rejection when building on Windows #723

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

Closed
davepagurek opened this issue Mar 12, 2025 · 7 comments · Fixed by #724
Closed

Unhandled promise rejection when building on Windows #723

davepagurek opened this issue Mar 12, 2025 · 7 comments · Fixed by #724
Labels
Bug Something isn't working

Comments

@davepagurek
Copy link
Collaborator

Most appropriate sections of the p5.js website?

Other (specify if possible)

What is your operating system?

Windows

Web browser and version

N/A

Actual Behavior

When running npm run dev on Windows, we sometimes encounter this error:

Astro detected an unhandled rejection. Here's the stack trace:
Error: Build failed with 1 error:
node_modules/@swc/html/binding.js:101:31: ERROR: No loader is configured for ".node" files: node_modules/@swc/html-win32-x64-msvc/swc-html.win32-x64-msvc.node
    at failureErrorWithLog (C:\dev\p5.js-website\node_modules\esbuild\lib\main.js:1651:15)
    at C:\dev\p5.js-website\node_modules\esbuild\lib\main.js:1059:25
    at C:\dev\p5.js-website\node_modules\esbuild\lib\main.js:1527:9
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

@lukeplowden just encountered this, and it was also reported a month ago here #698 (comment) although we weren't able to reproduce it reliably.

This error seems flaky: rerunning the server again, it didn't happen for Luke.

Some possible next steps here:

  • Can we figure out under what circumstances this error triggers, so that we can debug it further?
  • In Copy Button Issue with Multiple Syntax Signatures in Reference Page #698 (comment), the error weas bypassed by commenting out code that used the @swc/html library. If that is indeed the cause, are there ways we can avoid using this library?
  • Can we offer alternative instructions for Windows users, either running through Docker or WSL?

Expected Behavior

Ideally we have no errors when building 🙂

Steps to reproduce

Not sure yet, if anyone figures out exactly what circumstances lead to this, that would help!

Would you like to work on the issue?

I don't actually have Windows myself so I'm unable to work on this

@davepagurek davepagurek added the Bug Something isn't working label Mar 12, 2025
@limzykenneth
Copy link
Member

I think it is @swc/html not working on Windows. I have not had a chance to dig deeper but the codebase is Rust as well so would be also more challenging. Dev server should be working though.

@swc/html is significantly faster than any other alternative and is needed to achieve the build time reduction to resolve #647. If we can test and dig a bit deeper we can bring the issue back to @swc/html

@davepagurek
Copy link
Collaborator Author

davepagurek commented Mar 12, 2025

Is the fast-compress script only intended for use at build time? I wonder if @swc/html has any effects that happen just by importing it. npm run dev seems to only flakily cause this error to occur so it doesn't seem to actually be critical to operation, but something is causing it anyway. If just encountering the import is causing issues, maybe there's a way to await import('@swc/html') right before it gets used so it defers reading the library at all until it's about to be used?

@HritvikBhatia
Copy link
Contributor

HritvikBhatia commented Mar 12, 2025

Hey everyone,

I’m also encountering the same issue when running npm run dev on Windows:

I’ve tried some things to debug and fix it:

Checked dependencies: Ran npm ls @swc/html to confirm where it's used.
Disabled SWC transform: Used $env:ASTRO_DISABLE_SWC_TRANSFORM="true"; npm run dev but not worked.
Reinstalled SWC manually: Ran npm i @swc/core @swc/html --force, but still no worked

Image
Tried git bash don't know why just in case it might work but still not fixed
Image

I tested npm run build and npm run preview, and they work fine. However, npm run dev still fails

@lukeplowden
Copy link
Collaborator

lukeplowden commented Mar 12, 2025

Specifying the loader for .node files in the astro config seems to fix it. It's a bit of a funny one as it's going through astro->vite->esbuild. But I'm getting strangely inconsistent results with this as it needs an output path which we don't have in dev mode. I think it only silences the error if you have previously built

  vite: {
    rollupOptions: {
      external: ["/src/scripts/*"],
    },
    optimizeDeps: {
      esbuildOptions: {
        loader: {'.node': 'file'},
      }
    }
  },

@HritvikBhatia
Copy link
Contributor

HritvikBhatia commented Mar 12, 2025

@lukeplowden I'm still running into the some error.

Image

so, i have

vite: {
    optimizeDeps: {
      exclude: ["@swc/html"]
    },
    rollupOptions: {
      external: ["/src/scripts/*"],
    },
  }

Image

i think it is solved

@HritvikBhatia
Copy link
Contributor

Should I open a PR? 😺

@limzykenneth
Copy link
Member

Theoretically it should only be imported on build but for it to be imported on dev is likely Astro's problem for the dev run. In any case if there is a solution to get it working via the config change, do go for it.

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

Successfully merging a pull request may close this issue.

4 participants