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: Maximum call stack size exceeded: _stream_writable.js:274 #14778

Closed
p3x-robot opened this issue Aug 11, 2017 · 4 comments
Closed
Labels
stream Issues and PRs related to the stream subsystem. wrong repo Issues that should be opened in another repository.

Comments

@p3x-robot
Copy link

p3x-robot commented Aug 11, 2017

Ciao!

How are you?

  • Version:
    8.3.0
  • Platform:
    Linux workstation 4.10.0-30-generic fix LICENSE #34~16.04.1-Ubuntu SMP Wed Aug 2 02:13:56 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
  • Subsystem:
    Linux Mint / Debian / Windows etc..

I have been using my own crypto based on AES, with an additional 512 rounds, but my program is not working anymore and have no idea to get around this, the error:

patrikx3@workstation:~/ramdisk$ ~/Projects/patrikx3/p3x/aes-folder/index.js 
Generated command:
krip read krip.krip

Password? ****************
_stream_writable.js:274
    ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
          ^

RangeError: Maximum call stack size exceeded
    at Decipher.Writable.write (_stream_writable.js:274:11)
    at Decipher.ondata (_stream_readable.js:628:20)
    at emitOne (events.js:115:13)
    at Decipher.emit (events.js:210:7)
    at addChunk (_stream_readable.js:252:12)
    at readableAddChunk (_stream_readable.js:239:11)
    at Decipher.Readable.push (_stream_readable.js:197:10)
    at Decipher.Transform.push (_stream_transform.js:147:32)
    at Decipher._transform (crypto.js:150:8)
    at Decipher.Transform._read (_stream_transform.js:186:10)

The not liking code is:

const settings = require('./settings');

module.exports = (crypto, cipherPipe, password) => {

    const roundCipher = (lastCipherPipe) => {
        const newCipher = crypto(settings.cypher, password);
        newCipher.on('error', (err) => {throw err} );
        return lastCipherPipe.pipe(newCipher)
    }

    let round = 0;
    while(round++ < settings.rounds) {
        cipherPipe = roundCipher(cipherPipe);
    }
    return cipherPipe;
}
@p3x-robot p3x-robot changed the title _stream_writable.js:274 RangeError: Maximum call stack size exceeded: _stream_writable.js:274 Aug 11, 2017
@p3x-robot
Copy link
Author

Oh, it only started doing this error since like 8.2 i think, all before since like 6.7 it was working.

@mscdex mscdex added stream Issues and PRs related to the stream subsystem. v8.x labels Aug 11, 2017
@p3x-robot
Copy link
Author

p3x-robot commented Aug 12, 2017

I fixed it like this:

const settings = require('./settings');
const utils = require('corifeus-utils')

module.exports = async (crypto, cipherPipe, password) => {

    const { resolve, reject, promise} = utils.promise.deferred();

    const roundCipher = (lastCipherPipe) => {
        const newCipher = crypto(settings.cypher, password);
        newCipher.on('error', (err) => {throw err} );
        return lastCipherPipe.pipe(newCipher)
    }

    /*
    let round = 0;
    while(round++ < settings.rounds) {
        cipherPipe = roundCipher(cipherPipe);
    }
    */

    let round = 0;
    const tick = () => {
        setTimeout(() => {
            if (round++ > settings.rounds - 1) {
                resolve(cipherPipe);
            } else {
                cipherPipe = roundCipher(cipherPipe);
                tick();
            }
        }, 10)
    }
    tick();

    return promise;
}

process.tick() was not working, but still, why is this an error?

@p3x-robot
Copy link
Author

Well, the problem is if I want to encrypt a bigger folder like 25MB then I get the same error, so it is not a very good hack. Do you have an idea to make it work without this error?
Why I get a RangeError: Maximum call stack size exceeded or why can't I just set in code the allowed stack size?

@bnoordhuis
Copy link
Member

This looks like it should have been posted to the help repo instead. I'll close this out, can reopen if there is reason to believe it's a bug in node.js itself.

@bnoordhuis bnoordhuis added the wrong repo Issues that should be opened in another repository. label Sep 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stream Issues and PRs related to the stream subsystem. wrong repo Issues that should be opened in another repository.
Projects
None yet
Development

No branches or pull requests

3 participants