-
Notifications
You must be signed in to change notification settings - Fork 10
Uncaught TypeError when future.compatibilityVersion: 5 and loading third-party scripts via @nuxt/scripts. #302
Copy link
Copy link
Closed
Labels
Description
Environment
| Operating system | Linux 5.0 (Macintosh) |
| CPU | Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz (8 cores) |
| Node.js version | v22.22.0 |
| nuxt/cli version | 3.34.0 |
| Package manager | pnpm@8.15.6 |
| Nuxt version | 4.4.2 |
| Nitro version | 2.13.2 |
| Builder | vite@7.3.1 |
| Config | compatibilityDate, devtools, future, modules |
| Modules | @nuxt/hints@1.0.2, @nuxt/scripts@0.13.2 |
Reproduction
https://stackblitz.com/edit/nuxt-starter-wyi5hapn
Describe the bug
When you have the following in your Nuxt config:
future: {
compatibilityVersion: 5
},
and some third-party script is added via useScript or scripts.globals.[key], @nuxt/hints errors out with the following error:
Uncaught TypeError: can't access property "then", nuxtApp.callHook(...) is undefined
NuxtJS 15
onScriptAdded
observer
setup
<anonymous>
fn
runWithContext
callWithNuxt
runWithContext
run
runWithContext
applyPlugin
executePlugin
applyPlugins
initApp
<anonymous>
[plugin.client.js:96:15]
I wasn't able to reproduce it in the minimal repro, but in my app it actually throws me to the error page and breaks the app completely.
The reason is due to this change that results in callHook now being able to return void instead of always returning a promise.
A confirmed workaround is to set experimental.asyncCallHook: true in your Nuxt config, but this will inevitably break at some point.
Additional context
No response
Logs
Reactions are currently unavailable