serviejs / popsicle

Simple HTTP requests for node and the browser
MIT License
246 stars 19 forks source link

Exception 'stream.on is not a function' when ArrayBuffer is sent from a node.js app #139

Closed sangelastro closed 3 years ago

sangelastro commented 3 years ago

Hi,

by using the following (nodejs) code:

var popsicle = require('popsicle');

const buffer = new ArrayBuffer(8);
const uint8 = new Uint8Array(buffer);
uint8.set([1, 2, 3], 3);

const res = popsicle.fetch('http://localhost:52128/arraybuffer',
{
  method: 'POST',
  body: buffer,
  omitDefaultHeaders: true,
  headers: {'Content-Type':'application/octet-stream'}
}).then((res) => console.log(res));

the following exception gets raised 'stream.on is not a function'' (tested with node v12.18.3).

Thanks Sergio A.

blakeembrey commented 3 years ago

What version of popsicle are you using?

sangelastro commented 3 years ago

I am using the following versions:

  1. popsicle: ^12.0.6;
  2. servie: ^4.3.3.
blakeembrey commented 3 years ago

This is fixed with the latest release of popsicle-transport-http (https://github.com/serviejs/popsicle-transport-http/commit/0a22abc102b55905e7132794294dde3189b0769f), if you do npm install popsicle again you should see the latest version installed. I'm back from a vacation now, so I'll look into improving the cross-repo coverage ASAP along with supporting other typed arrays.

sangelastro commented 3 years ago

I tested the latest version of the popsicle-transport-http package in my project. Now the request in nodejs works smoothly, without exceptions. Thank you so much for the bug fixing. No big deal, everyone deserves a vacation. I look forward to seeing improved the cross-repo coverage.

sangelastro commented 3 years ago

Is the dependency "popsicle-transport-http" in popsicle package.json supposed to be updated (from ^1.0.8 to ^1.0.9)?

blakeembrey commented 3 years ago

That’s irrelevant because versioning isn’t pinned, anyone installing will get the latest release.