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

Should bent be split into Node.js and browser versions? #94

Open
aral opened this issue Apr 7, 2020 · 2 comments
Open

Should bent be split into Node.js and browser versions? #94

aral opened this issue Apr 7, 2020 · 2 comments

Comments

@aral
Copy link
Contributor

aral commented Apr 7, 2020

I noticed, while adding responseHeaders to error objects (https://github.com/mikeal/bent/pull/93/files), that the Node and Browser implementations differ in what the responses return. On Browser (unless I’m missing something), I couldn’t see the same details in the response objects as on Node. (For example, no header information.)

Not having looked at depth into the underlying Browser implementation, I’m wondering:

  • Should bent be split into two modules (node, browser) with different expectations
  • Should the browser and node implementations be made to match perfectly (if possible)

Thoughts?

(This is not a huge issue for me personally and definitely not a hill I wish to die on as I’m only using it in Node but I’m assuming it might be confusing for folks who use it in both Node and Browser if they encounter different behaviour.)

Please feel free to close if not a priority for project goals.

@mikeal
Copy link
Owner

mikeal commented Apr 7, 2020

So, this is a little tricky.

While I strive for parity, I do find it a little aggressive to actually prevent exposing browser/node.js specific details in each environment.

Right now, if you don’t do use body decoding, the response object is the native Node.js response or the Fetch response object, which obviously have different API’s. My goal is, over time, to simply decorate each object to provide consistent interfaces across both. We’re already doing this for a bunch of properties but I suspect some are still missing, and we’re missing even more useful info on StatusError which you’ve obviously noticed.

Anywhere that we don’t have consistently available access to information in both environments should be considered a bug.

@mikeal
Copy link
Owner

mikeal commented Apr 13, 2020

Just pushed a big improvement in this direction #96

Not sure if that resolves this issue for you or not, but it’s a move in the right direction.

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