Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Safari date-object issues #176

Open
johnfumaster opened this issue Nov 20, 2019 · 8 comments
Open

Safari date-object issues #176

johnfumaster opened this issue Nov 20, 2019 · 8 comments

Comments

@johnfumaster
Copy link

Error

undefined is not an object (evaluating 'this.epoch=null')

I'm receiving errors from our monitoring software that people are experiencing. I don't know what's causing it. I've thrown invalid dates, invalid strings, NaN into spacetime(), and I can't get it to throw this error.

The line reports is coming from: webpack:///./node_modules/spacetime/builds/spacetime.js:3826:0:in 'epoch'

@spencermountain
Copy link
Owner

thanks john, that sounds weird.
Are you using it with .bind() or something? it's a pretty generic this call. this should always exist, unless being called in a fancy way.

@johnfumaster
Copy link
Author

No, not any special way. I am doing something like this mostly.
spacetime(date).isValid()

where date can be of new Date(), new Date('2016-01-01'), a number like 1488370835081, NaN, null, undefined etc.

@johnfumaster
Copy link
Author

I've just put in a try catch around the call to instantiate a spacetime to log the input that is causing the error. I'll let you know my findings as soon as I find out.

@johnfumaster
Copy link
Author

Ok. Here's what caused the errors. The code was instantiating with:
let s = spacetime(”2019-11-21”)
As well as
let a = spacetime("Thu Nov 21 2019 15:48:12 GMT+1100 (AEDT)")

They seem to produce dates, it's just that spacetime code throws an error for some bizarre reason.

Any ideas?

@johnfumaster
Copy link
Author

johnfumaster commented Nov 21, 2019

Hi, we can finally replicate the error. It seems to be an issue with Safari 11 on desktop. I can't replicate the error everytime I load, but it is happening intermittently on Safari 11

@spencermountain
Copy link
Owner

thanks John, that's really helpful.
I'm happy to fix this. The second date appears not parse into a valid date.
If there's a weird browser issue, we should be able to set some kind of guard or polyfill.

what are the actual method calls, to reproduce it?

@spencermountain
Copy link
Owner

yeah, it seems safari has some opinions in it's Date Object. That could be it.
Either way, the no-this error shouldn't happen. We should figure it out.
cheers

@johnfumaster
Copy link
Author

Thanks Spencer. Much appreciated.

The stack overflow only reports issues with 'yyyy-MM-dd' format. But we are also getting errors when using 1574312228115 and Mon Nov 25 2019 11:00:00 GMT+1100 (AEDT).

@spencermountain spencermountain changed the title undefined is not an object (evaluating 'this.epoch=null') Safari date-object issues Jan 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants