davestewart / nuxt-content-assets

Enable locally-located assets in Nuxt Content
https://npmjs.com/package/nuxt-content-assets
108 stars 7 forks source link

Nitro Build gets stuck at "You can preview this build using node .output/server/index.mjs" and doesn't complete when using nuxt-content-assets #49

Closed brunopbarbosa closed 2 months ago

brunopbarbosa commented 9 months ago

Background

Using this module to serve relative images with nuxt content, runs as expected while in dev.

Issue

When running npm run build (both on server or local) with the module enabled on the nuxt.config file, the build goes all the way through until this point and then just hangs indefinitely.

removing this module from the module list in the config file seems to let the build run as normal.

Any insight would be highly appreciated!

davestewart commented 9 months ago

Hello,

Sorry to leave you hanging! (EDIT: literally 😆)

What version of Nuxt are you running (run the code below to find out) ?

echo -e "\nNode `node -v`\n" && npm list nuxt @nuxt/content nuxt-content-assets --depth=0

If > 3.6.5 it could be related to this:

Can you confirm?

See also the linked issue 169. Right now it seems a few modules are causing this, the cause is not yet known, but I suspect it's something to do with Nuxt > 3.7.0.

Hecatron commented 9 months ago

Run into this problem myself under windows. Fixing the nuxt version to 3.6.5 fixed it, it does appear to be a 3.7 issue

brunopbarbosa commented 9 months ago

Hi, yes, i downgraded to 3.6.5 and it does in fact solve it!

I'll be keeping an eye out on those other issues you mentioned, at the moment fixing on 3.6.5 is not problematic.

And thanks again for your help! I didn't have to hang for too long 😆

I'll leave the issue open in case someone else ends up here, but feel free to close it if you think it's more appropriate!

davestewart commented 9 months ago

Whoop!

Yes, let's leave it open until it – hopefully – gets solved upstream.

Thanks for reporting back!

davestewart commented 9 months ago

This issue is now being tracked in the Nuxt CLI repo:

Hecatron commented 7 months ago

I think I've found a temporary workaround that allows us to use the latest version of nuxt with this module Based on these links

I tried adding the following to the nuxt config

export default defineNuxtConfig({
  hooks: {
    close: (nuxt) => {
      if (!nuxt.options._prepare)
        process.exit()
    }
  }
})

Then I run nuxi generate and it all seems to work / finish under nuxt 3.8.1 not ideal but at least I think we can use the latest nuxt until there's a better fix

ayZagen commented 7 months ago

@Hecatron that resolves the issue but is there any downside using it?

Hecatron commented 7 months ago

I don't think so but I can't be 100% certain, for now it's a sort of temporary fix until nuxt sort they're end out, since I think it's not the only module it affects

miclgael commented 3 months ago

I'm not sure if related / useful but one potential downside to the workaround is I had to add an env check in order to keep Vitest working with @nuxt/test-utils

nuxt.config.{js|ts}

export default defineNuxtConfig({
  hooks: {
    close: (nuxt) => {
+     const isTesting = process.env.NODE_ENV === 'test'
+     if (!nuxt.options._prepare && !isTesting) {
         process.exit()
    }
  }
})

package.json

"scripts": {
+  "test": "NODE_ENV=test && vitest"
 }

This stops Vitest outputting nothing to the console.

Also noticed this message when running Vitest.

[Content Assets] Your browser does not support WebSocket

PS absolutely adore this module thank you for making it 🙏

YanDevDe commented 3 months ago

I'm also facing the issue of where I use yarn install gets stuck at "✔ Types generated in .nuxt "

with the temporary solution of "hooks" in nuxt.config.ts seems to fix for yarn build, but for yarn install its still there.

I have following versions:

├── @nuxt/content@2.12.1 ├── nuxt-content-assets@1.3.3 └── nuxt@3.7.4

danielroe commented 3 months ago

The issue here, as explained in https://github.com/nuxt/cli/issues/169#issuecomment-1714201831, is that watchers were not being closed out.

I've made a couple of changes to close watchers gracefully when Nuxt exits, as well as avoiding starting some of them in the first place when not in development mode.

I hope this helps (https://github.com/davestewart/nuxt-content-assets/pull/65). 🙏