https://github.com/archieDeveloper/nuxt-bug
npm install
npm run dev
go to main page to website.
check the console.
in the console inscription [object Error] true Request failed with status code 404
in the console inscription [object Error] false Request failed with status code 404
Linux Ubuntu 18.04
npm version 6.7.0
node version v11.12.0
"@nuxtjs/axios": "^5.4.1"
"nuxt": "^2.5.1"
async asyncData ({ $axios }) {
const toString = {}.toString;
try {
await $axios.get('https://google.com/test'); // should return 404 error
} catch (error) {
// expected - [object Error] true Request failed with status code 404
// we get - [object Error] false Request failed with status code 404
console.log(toString.call(error), error instanceof Error, error);
}
}
When an http error occurs, the $axios module throws an exception and translates the code into the catch branch. An object of type Error falls into the error variable, but the instanceof operator shows the opposite. Also error instanceof Object returns false in the result.
This behavior is observed only when the npm run dev application is running. When running npm run build npm run start works correctly.
I also encountered the same problem锛寃hen i use code:
new Date() instanceof Date
In the dev mode:
It return false
in the prod mode:
It return true
Thanks for your contribution to Nuxt.js!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you would like this issue to remain open:
Issues that are labeled as pending
will not be automatically marked as stale.
Apparently nothing has been done on this so.. just bumping this to show it's still an issue
Confirmed this is still an issue... in dev mode, any prop with type: Date
will throw console warnings in dev mode. Because new Date() instance of Date
returns false.
eg. using Buefy DatePicker, I see this:
core_1 | [Vue warn]: Invalid prop: type check failed for prop "selectedDate". Expected Date, Array, got Date
core_1 |
core_1 | found in
core_1 |
core_1 | ---> <BDatepickerTableRow>
core_1 | <BDatepickerTable>
core_1 | <BDropdownItem>
core_1 | <BDropdown>
core_1 | <BDatepicker>
My workaround is to only populate the value after the component is mounted, which is a pain.
This bug is still relevant with today's version of nuxt and nuxt-edge. You can still install @archieDeveloper 's project and reproduce the bug today!
I'm unable to use https://github.com/typestack/class-validator on my Nuxt project in dev mode, because it uses instanceof
internally (for Arrays, Sets, Maps, Objects...)
The only workaround I found is to write the following in nuxt.config.js
:
render: {
bundleRenderer: {
runInNewContext: false,
},
},
@MaximeCouasnon , fine this works for me!
Most helpful comment
Apparently nothing has been done on this so.. just bumping this to show it's still an issue