fix: consola crashes due to 'logObj.date.getTime is not a function'
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 3.3k
- Forks
- 214
- Avg merge
- 13h 22m
- Merged PRs (30d)
- 18
Description
🐛 The bug
The Nuxt 3 application that I'm currently developing using Typescript has devtools enaled and always throws an error during the initialization which stops the whole page from loading correctly.
index.mjs:48 [nuxt] error caught during app initialization TypeError: logObj.date.getTime is not a function
at Consola._logFn (core.mjs:353:70)
at Consola.log (core.mjs:306:19)
at dev-server-logs.js:28:8
at index.mjs:48:66
at index.mjs:48:56
at async dev-server-logs.js:35:4
at async setup (client.mjs:38:36)
at async applyPlugin (nuxt.js:137:25)
at async executePlugin (nuxt.js:173:9)
at async applyPlugins (nuxt.js:187:5)
It seems that Consola is trying to use the method getTime even though logObj.date is a String?
It happens when
"[Vue warn]: Property undefined was accessed during render but is not defined on instance.
" at Proxy.<anonymous> (eval-4efcead9.cdp)""
is called, and for some reason logObj.date is overwritten by the Object.assign function to a string instead of a Date object.
Could this be a bug of the Consola dependency or is this due to dev-server-logs.js sending a wrongly typed object?
🛠️ To reproduce
- Set
devtoolsenabled
🌈 Expected behavior
Page not completely halting when this error occurs
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure in a Nuxt 3 application with devtools enabled, then inspect dev-server-logs.js and the Consola._logFn stack shown in the report. Trace how the log object's date is passed into logging and verify the initialization no longer halts when this warning is emitted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nuxt, typescript
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100