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

RangeError: Invalid typed array length: -4095 #363

Open
boompig opened this issue Aug 9, 2019 · 13 comments
Open

RangeError: Invalid typed array length: -4095 #363

boompig opened this issue Aug 9, 2019 · 13 comments

Comments

@boompig
Copy link

boompig commented Aug 9, 2019

I'm trying to get express + spdy working together. I followed this walkthrough and encountered an error.

I'm pared down the example to a very simple case that consistently fails with the error below. I don't believe I'm making any obvious mistakes. To reproduce the error, visit the URL (server starts without errors).

$ node index.js
Running on https://localhost:8080
internal/buffer.js:941
class FastBuffer extends Uint8Array {}
^

RangeError: Invalid typed array length: -4095
    at new Uint8Array (<anonymous>)
    at new FastBuffer (internal/buffer.js:941:1)
    at Handle.onStreamRead [as onread] (internal/stream_base_commons.js:165:17)
    at Stream.<anonymous> (/Users/XXXXXX/node_modules/handle-thing/lib/handle.js:88:10)
    at Stream.emit (events.js:205:15)
    at endReadableNT (/Users/XXXXXX/node_modules/readable-stream/lib/_stream_readable.js:1077:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:9)

Using this code:

const fs = require('fs');
const express = require('express');
const spdy = require('spdy');

// constants
const port = process.env.PORT || 8080;

// app config
const app = express();
const options = {
	key: fs.readFileSync('certs/myserver.key'),
	cert: fs.readFileSync('certs/certbundle.pem'),
};

// routes
app.use('/', express.static('public'));

spdy.createServer(options, app).listen(port, (err) => {
	if(err) {
		console.error(err);
		return process.exit(1);
	}
	console.log(`Running on https://localhost:${port}`);
});

I have latest express and spdy:

{
  "devDependencies": {
    "express": "^4.17.1",
    "spdy": "^4.0.1"
  }
}

node version v12.4.0

Is this possibly related to this issue?

@boompig
Copy link
Author

boompig commented Aug 9, 2019

Small additions:

  1. public directory exists with index.html inside it.
  2. If I remove spdy and replace it with app.listen and visit the non-https URL then the server works as expected

Therefore I believe this is a bug with spdy module

@chranmat
Copy link

I also have this issue. I'm not using spdy directly, but through another module.

@AliasPedroKarim
Copy link

I work with spdy and it shows me the same error when I try to run the server

internal/buffer.js:788
class FastBuffer extends Uint8Array {}
^

RangeError: Invalid typed array length: -4095
    at new Uint8Array (<anonymous>)
    at new FastBuffer (internal/buffer.js:788:1)
    at Handle.onStreamRead [as onread] (internal/stream_base_commons.js:149:17)
    at Stream.<anonymous> (/home/xxxxxx/node_modules/handle-thing/lib/handle.js:88:10)
    at Stream.emit (events.js:202:15)
    at endReadableNT (/home/xxxxxx/node_modules/spdy-transport/node_modules/readable-stream/lib/_stream_readable.js:1077:12)

@SlyCaptainFlint
Copy link

I am also hitting the same issue when using express+spdy. Seems to go away if I disable the h2 protocol and don't attempt to provide a certificate, but that is the whole reason I want to use spdy in the first place.

@2234839
Copy link

2234839 commented Nov 18, 2019

I'm trying to get express + spdy working together. I followed this walkthrough and encountered an error.

I'm pared down the example to a very simple case that consistently fails with the error below. I don't believe I'm making any obvious mistakes. To reproduce the error, visit the URL (server starts without errors).

$ node index.js
Running on https://localhost:8080
internal/buffer.js:941
class FastBuffer extends Uint8Array {}
^

RangeError: Invalid typed array length: -4095
    at new Uint8Array (<anonymous>)
    at new FastBuffer (internal/buffer.js:941:1)
    at Handle.onStreamRead [as onread] (internal/stream_base_commons.js:165:17)
    at Stream.<anonymous> (/Users/XXXXXX/node_modules/handle-thing/lib/handle.js:88:10)
    at Stream.emit (events.js:205:15)
    at endReadableNT (/Users/XXXXXX/node_modules/readable-stream/lib/_stream_readable.js:1077:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:9)

Using this code:

const fs = require('fs');
const express = require('express');
const spdy = require('spdy');

// constants
const port = process.env.PORT || 8080;

// app config
const app = express();
const options = {
	key: fs.readFileSync('certs/myserver.key'),
	cert: fs.readFileSync('certs/certbundle.pem'),
};

// routes
app.use('/', express.static('public'));

spdy.createServer(options, app).listen(port, (err) => {
	if(err) {
		console.error(err);
		return process.exit(1);
	}
	console.log(`Running on https://localhost:${port}`);
});

I have latest express and spdy:

{
  "devDependencies": {
    "express": "^4.17.1",
    "spdy": "^4.0.1"
  }
}

node version v12.4.0

Is this possibly related to this issue?

是的,与node的版本有关 10 的版本没问题,我升级之后也遇到了相同的问题
Yes, there is no problem with the node version 10, I had the same problem with the upgrade

@newlukai
Copy link

newlukai commented Dec 18, 2019

The same for me.
Node@12.13.0
express@4.17.1
spdy@4.0.1

UPDATE: The referenced fix works for me.

@calaway
Copy link

calaway commented Dec 29, 2019

Can you please elaborate what the fix is for this issue?

I'm running into the same error on Node 12.8.1, but it works when I revert to Node 10.15.3. Is there a way to resolve the error on Node 12?

I really appreciate your help!

@luki1412
Copy link

Still broken on v12.14.1 and seems like no active maintainers.

@gareth-johnstone
Copy link

we're also having the same issues with SPDY

Is this even maintained??

@coxrichuk
Copy link

coxrichuk commented Feb 3, 2020

I am also experiencing this issue

node@13.5.0
express@4.14.0
spdy@3.3.3

Very simple app

const port = 3008;
const spdy = require('spdy');
const express = require('express');
const path = require('path');
const fs = require('fs');

const app = express()

app.get('*', (req, res) => {
    res
      .status(200)
      .json({message: 'ok'})
})
const options = {
    key: fs.readFileSync(__dirname + '/server.key'),
    cert:  fs.readFileSync(__dirname + '/server.cert')
}
console.log(options)
spdy
  .createServer(options, app)
  .listen(port, (error) => {
    if (error) {
      console.error(error)
      return process.exit(1)
    } else {
      console.log('Listening on port: ' + port + '.')
    }
  })

@evandrix
Copy link

evandrix commented Feb 12, 2020

bump

macOS Catalina 10.15.3
Node.JS v13.8.0

workaround right now is https://github.com/nvm-sh/nvm + v10.19.0

@StephanBijzitter
Copy link

It's fixed. When you update, make sure to manually inspect your yarn or npm lock file.
handle-thing (great name) must be at least at version 2.0.1

@Smileytear
Copy link

It's fixed. When you update, make sure to manually inspect your yarn or npm lock file. handle-thing (great name) must be at least at version 2.0.1

you are right, update webpack version can solve this quesiton

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

No branches or pull requests