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

importing tape causes crash when used in plv8 (a postgres js interpreter that uses v8) #413

Closed
max-l opened this issue Dec 14, 2017 · 5 comments
Labels

Comments

@max-l
Copy link

max-l commented Dec 14, 2017

https://github.com/plv8/plv8

this single line :

var test = require('tape');

causes the following exception:

{ Error: stdout maxBuffer exceeded
    at Socket.onChildStdout (child_process.js:328:14)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:246:13)
    at Socket.Readable.push (_stream_readable.js:208:10)
    at Pipe.onread (net.js:594:20)

note that plv8 is not a node environement, it cannot spawn child processes among other things,
it seems that tape is indirectly doing this.

I wanted to create my own test stream with :

test.createStream().on('data', line => {...});

to avoid using console.log or other things not available in plv8, but it seems
as if tape is using unavailable libs in it's initialization.

@ljharb
Copy link
Collaborator

ljharb commented Dec 14, 2017

This is a node lib; I'm not sure what plv8 is, but this library in no way is intended to support it.

What's the use case for running tests in it, if it doesn't provide the ability to launch child processes?

@max-l
Copy link
Author

max-l commented Dec 14, 2017

plv8 allows writing stored procedures in javascript that run inside a postgres database.

What's the use case for running tests in it, if it doesn't provide the ability to launch child processes?

Not sure I understand the question, plv8 does not allow launching child processes in order to restrict what a stored proc can do on the db server. The use case for running tests in pl8v is... to test the code that runs in plv8 !

I was under the impression that tape could run in a browser, from reading these issues it appears it doesn't :

The proposal suggested here : #88 seems like a nice way to separate the tape api from the node env, with the added benefits mentioned by the author.

@ljharb
Copy link
Collaborator

ljharb commented Dec 14, 2017

Yes, using browserify is how it's used in a browser; if you browserify tape first (by bundling your tests entry point, before running it in pl8v), do your crashing problems go away?

@max-l
Copy link
Author

max-l commented Dec 14, 2017

running with browserify solved the crash, now I get another crash at this line :

https://github.com/substack/tape/blob/master/lib/test.js#L18

since plv8 doesn't have a setTimeout method. I tried setting the variable to null, or do a do nothing function, when I do what, it crashes later on here:


function runTimeout(fun) {
    if (cachedSetTimeout === setTimeout) {
        //normal enviroments in sane situations
        return setTimeout(fun, 0);
    }
    // if setTimeout wasn't available but was latter defined
    if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
        cachedSetTimeout = setTimeout;
        return setTimeout(fun, 0);
    }
    try {
        // when when somebody has screwed with setTimeout but no I.E. maddness
        return cachedSetTimeout(fun, 0);
    } catch(e){
        try {
            // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
            return cachedSetTimeout.call(null, fun, 0);
        } catch(e){
            // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
            return cachedSetTimeout.call(this, fun, 0);
        }
    }
}

This code appears in my browserified bundle, not sure where it is from, I suppose it's a shim to emulate a browser env, the problem is that I'm not in a browser, nor am I in a Node env !

@ljharb
Copy link
Collaborator

ljharb commented Dec 14, 2017

Since tape is async by default, if you don't have setTimeout, there's just no way to run tape in that environment.

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

No branches or pull requests

2 participants