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

Passing Long.js to writeInt64 Fails with Type Error #86

Open
kbahr opened this issue Feb 6, 2018 · 3 comments
Open

Passing Long.js to writeInt64 Fails with Type Error #86

kbahr opened this issue Feb 6, 2018 · 3 comments

Comments

@kbahr
Copy link

kbahr commented Feb 6, 2018

I'm using nodejs, I have a transitive dependency on bytebuffer, and when I pass Long.UZERO I get a type error from this line:
https://github.com/dcodeIO/bytebuffer.js/blob/master/dist/bytebuffer-node.js#L1042

I've validated that UZero has the right structure, including the isLong property but that instanceof call fails. I know this is kind of a symptom of node but wouldn't it be better to have duck type checks rather than instanceof to allow better interop?

@dcodeIO
Copy link
Member

dcodeIO commented Feb 6, 2018

Might be that your node_modules has multiple (maybe nested) versions of the long package. We can use duck-typing there, but I'd not agree that it is generally better. For instance, if there'd be any breaking API-changes between the two (which is unlikely for long.js, but perfectly possible for other packages), things would go haywire anyway.

@kbahr
Copy link
Author

kbahr commented Feb 6, 2018

Sorry I was unclear - I didn't mean that duck typing is always better :) I just meant in this case, it's possible to have node_module versions that are slightly out of sync through no fault or intention and the error seems nonsensical at first blush.

I'll check that I'm using a consistent version of the long package but as I said, this is a transitive dependency and doesn't seem sustainable if I end up needing to reconcile across multiple dependencies. Maybe that's a n00b thing to say - I'm hardly a NodeJS master :)

@kbahr
Copy link
Author

kbahr commented Feb 8, 2018

Alright, I've verified that both the library I'm using that depends on ByteBuffer/Long matches the version that I have in my package-lock file. It seems that they still conflict because the dependencies/modules don't collapse to a single source. Is this possibly an artifact of Flow types or Babel or some build tool silliness interacting with node_modules?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants