Skip to content

Commit de9baa3

Browse files
committed
fix: improve client injection error message
1 parent cb5ddc6 commit de9baa3

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

  • packages/devtools/src/runtime/plugins/view

packages/devtools/src/runtime/plugins/view/client.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,14 @@ export async function setupDevToolsClient({
128128
iframe.id = 'nuxt-devtools-iframe'
129129
iframe.src = initialUrl
130130
iframe.onload = async () => {
131-
await waitForClientInjection()
132-
client.syncClient()
131+
try {
132+
await waitForClientInjection()
133+
client.syncClient()
134+
}
135+
catch (e) {
136+
console.error('Nuxt DevTools client injection failed')
137+
console.error(e)
138+
}
133139
}
134140
}
135141
catch (e) {
@@ -141,12 +147,13 @@ export async function setupDevToolsClient({
141147
}
142148

143149
function waitForClientInjection(retry = 10, timeout = 200) {
150+
let lastError: any
144151
const test = () => {
145152
try {
146153
return !!iframe?.contentWindow?.__NUXT_DEVTOOLS_VIEW__
147154
}
148155
catch (e) {
149-
156+
lastError = e
150157
}
151158
return false
152159
}
@@ -162,8 +169,7 @@ export async function setupDevToolsClient({
162169
}
163170
else if (retry-- <= 0) {
164171
clearInterval(interval)
165-
// eslint-disable-next-line prefer-promise-reject-errors
166-
reject('Nuxt DevTools client injection failed')
172+
reject(lastError)
167173
}
168174
}, timeout)
169175
})

0 commit comments

Comments
 (0)