Giter VIP home page Giter VIP logo

node-process's People

Contributors

calvinmetcalf avatar defunctzombie avatar der-on avatar eventualbuddha avatar feross avatar ilgooz avatar joeduncan avatar jtangelder avatar kevinptt0323 avatar kumavis avatar pdehaan avatar ptarjan avatar raynos avatar twolfson avatar zenflow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-process's Issues

Extend even emitter instead of noop'ing those methods

Is there a reason to noop the event emitter methods instead of just extending from the event emitter?

I was thinking of patching process.on('uncaughtException', function(){}) with window.onerror to handle this in the browser, but I would have to also patch these methods. I could submit a PR with all of this if that is something you are interested in having. Let me know!

missing process.versions

Hi,
I'm using node-bindings which has this line that uses process.versions. I'm also using browserify which uses this module.
From this issue it's quite clear to me that shimming wouldn't make sense but would it be okay to add process.versions in this module so that it doesn't throw an error?

Safari on IOS 9.3.1: problem since version 0.11.4

I'm building an application with the following libraries:

  • angular 2.0.0-rc.4
  • webpack 1.13.1

Some angular components do not immediately render to the screen when navigating to a new page. If the user taps the screen, the components are then rendered.

This was not a problem in version 0.11.3.
This problem exists in versions 0.11.4, 0.11.5 and 0.11.6.

My webpack config does not contain an entry for devtools.

Please let me know what additional details I can provide.

nextTick() fails when using an addEventListener polyfill in IE8

If I use a polyfill to provide addEventListener for IE8, which is required by other modules that I need to use, process.nextTick will use postMessage. In the listener that is created, it is assumed that event.stopPropagation() exists and that event.source will be a reference to the window object, but this is not the case in IE8 with the shim. As a result, the callback passed to nextTick never gets called.

I'm using the polyfill provided by mozilla on this page: https://developer.mozilla.org/en-US/docs/Web/API/EventTarget.addEventListener

I'll be submitting a pull request to fix this.

What license is your software?

Please could you clarify what license your software is. I can't package it without a license declaration somewhere.

It would also be great if you could include a copy of the license you have chosen (eg, MIT), usually in a file called LICENSE.

Thanks!

New versions breaking

// cached from whatever global is present so that test runners that stub it don't break things.
var cachedSetTimeout = setTimeout;
var cachedClearTimeout = clearTimeout;

ev.source is null in Firefox extensions

tl;dr In Firefox browser extensions, ev.source is null for postMessages.

I am writing a Pinboard.in extension on Crossrider and trying to use browserify to:

  • Get some nice APIs for the extension
  • Experimentation with browserify for extensions

I just caught a bug which shows ev.source is null inside of the extension. I will submit a PR some time in the future (I am currently have awake).

"Instrumented" process.nextTicket
Selection_005

Proof that ev.source is null
Selection_006

support process.chdir

BrowserFS provides a basic implementation of chdir and cwd in its own internal implementation of process. Would it be possible to include a similar implementation into this module, as a slight step up from the current stubs?

NPM?

Just wondering if this module is on npm, couldn't find it when searching around so just want to make sure if its there or not.

process.stdout.write ≈ console.log

Is it possible to have an early implementation of process.stdout.write with console.log()?

What would be also awesome is process.stderr.writeconsole.error

process.versions.node is undefined

I am doing browserify of “pdf2png-mp” npm module with following steps:

  1. $ sudo npm install pdf2png-mp
  2. $ browserify -r pdf2png-mp -o bundle.js
  3. Created a html file that includes the following:
 <body>
  <script src="bundle.js"></script>
  <script> 
    var md = require('pdf2png-mp');
 </script>
</body>

Actual Results:
“TypeError: Cannot read property 'split' of undefined” at bundle.js:667

var version = process.versions.node.split('.').map(function (value) {
return parseInt(value, 10);
});

Configuration:
Processor 2.5 GHz Intel Core i5
Memory 4 GB 1333 MHz DDR3
Software Mac OS X 10.9.4 (13E28)

Version & Build:
browserify v12.0.0
npm v3.3.8

process.hrtime()

example:

hrtime = process.hrtime || require('./hrtime.js')

function runTest() {
  var time = hrtime()
  setTimeout(function() {
    var diff = hrtime(time)
    // benchmark took 1234000000 nanoseconds
    console.log('benchmark took %d nanoseconds', diff[0] * 1e9 + diff[1])
    console.log(diff)
    runTest()
  }, 1234)
}

runTest()

Error: Unable to get property 'length' of undefined or null reference

Hi,

From time to time (very seldom, probably less than one of every million user sessions) we see the error Error: Unable to get property 'length' of undefined or null reference logged for a user and we tracked it to the if (currentQueue.length) { statement in cleanUpNextTick() in browser.js.

It also seems like it's only affect users using IE 11, we have not seen this for FF or Chrome:

User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; .NET4.0E; .NET4.0C; .NET CLR 3.5.30729; .NET CLR 2.0.50727; .NET CLR 3.0.30729; McAfee; InfoPath.3; GWX:DOWNLOADED; rv:11.0) like Gecko

Our best guess of the root cause is that for some reason the timeout for cleanUpNextTick triggers after the row where currentQueue is set to null but before the timer been cancelled by clearTimeout, i.e. some kind of race condition:

function drainQueue() {
    if (draining) {
        return;
    }
    var timeout = setTimeout(cleanUpNextTick);
    draining = true;

    var len = queue.length;
    while(len) {
        currentQueue = queue;
        ...
        ..
        }
        queueIndex = -1;
        len = queue.length;
    }
    currentQueue = null;
    draining = false;
    clearTimeout(timeout);
}

A possible solution would be to replace currentQueue = null; with currentQueue = []; unless you can identify any unintended consequences of such a change.

errors are not necessary in some cases

I think there is a specification error in the code

Uncaught Error: process.binding is not supported
    at Object.process.binding (suman.js:293)
    at Object.<anonymous> (suman.js:51174)
    at Object.module.exports.100 (suman.js:51178)
    at __webpack_require__ (suman.js:20)
    at Object.<anonymous> (suman.js:3417)
    at __webpack_require__ (suman.js:20)
    at Object.<anonymous> (suman.js:38562)
    at Object.<anonymous> (suman.js:39238)
    at __webpack_require__ (suman.js:20)
    at Object.<anonymous> (suman.js:80743)

It would be much better if process.binding() and process.chdir() were no-ops.
Throwing an error literally just breaks things, there is no point in polyfilling functions and just throwing an error, it doesn't make any sense. If the behavior is not supported in the browser just make it a noop. I hope this makes sense to you!

As you can see, in your existing code process.cwd() is pretty much a no-op even though it's not supported in the browser really either.

process.binding = function (name) {
    throw new Error('process.binding is not supported');  //does nobody any favors
};

process.cwd = function () { return '/' };

process.chdir = function (dir) {
    throw new Error('process.chdir is not supported');  // does nobody any favors
};

process.nextTick is slow

setTimeout is clamped down to 4ms and even more when tab is hidden.
I saw some old PR attempt at using Observer PostMessage immidate and other but you still use setTimeout and that came back and bite us when transferring data webtorrent/webtorrent#1568

Could you look into using something faster then setTimeout?

process.execArgv is undefined

looking for process.execArgv

in this codebase, it should just be an empty array

process.execArgv = []

I call this in my code:

var execArgs = process.execArgv.slice(0);

and it will obviously error out because apparently process.execArgv is not defined.

please and thank you

currentQueue is null in drainQueue

I'm getting an error in Firefox where currentQueue is null inside of drainQueue in babel-core/browser.js. From stepping through the code, there appears to be a race condition between two instances of drainQueue running at once. This is what is happening:

  1. drainQueue starts the first time: queueIndex is -1, queue has one item in it
  2. draining is set to true
  3. setTimeout(cleanUpNextTick) called
  4. currentQueue is set to queue, queue is set to an empty array
  5. queueIndex compared to length of queue and then incremented
  6. currentQueue[queueIndex].run() called
  7. At this point, control goes to the cleanUpNextTick scheduled by drainQueue
  8. draining set to false
  9. cleanUpNextTick sets queue to currentQueue and calls drainQueue, starting a second instance of drainQueue
  10. currentQueue set to a queue (which is just what it was before
  11. Because queueIndex is already 1, no new functions are run
  12. queueIndex set to -1
  13. currentQueue is set to null
  14. Second drainQueue completes
  15. First drainQueue regains control
  16. queueIndex is -1, because of second drainQueue
  17. queueIndex is less than len, so currentQueue[queueIndex].run() is called
  18. Exception because currentQueue is null

I've only observed this problem in Firefox, and usually only under very specific conditions (usually only the first time the page is loaded). We think this is causing problems for us downstream with Babel, Reflux, and React, so a fix would be greatly appreciated!

missing: process.stdout

hi, process.stdout is missing. Would be really great to have a simple implementation for that!

0.11.2 breaks IE11 compat

I don't have the necessary environment right now to be able to repro this in a way that I can share. In a nutshell this is how I would presume you would repro this issue.

Environment Windows 7/IE 11

Some stuff that goes into the <head/> tag.

<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<script src='https://cdnjs.cloudflare.com/ajax/libs/core-js/2.1.3/shim.min.js' type='text/javascript'></script>

Using webpack with the following config to inject bluebird as the default Promise implementation everywhere. Webpack entry config as follows:

entry: [
  'any-promise/register/bluebird',
  'expose?Promise!any-promise', // make bluebird the de-facto Promise everywhere
  ...
],
...

In this case I was using popsicle to fetch a resource (JSON document) and that's when the issue occurred. There is a relationship between any-promise and popsicle for that reason I think it might be necessary to use popsicle for a successful repro.

See comments on this commit for more information.

process.stdout

Would be great to have it implemented.

Many packages would run simply by having process.stdout.write() (I'm using browserify).

process.version should be shimmed

I was trying to use bluebird on the browser, and it's trying to do a process.version.indexOf, and since it's missing from the shims, its failing before the module can 'takeof'.

//...
process.title = 'browser';
process.browser = true;
process.env = {};
process.argv = [];
process.version = '0.10.26'; // maybe always put the current node version that executed the code? 

I'm using it in browserify btw

Better process.nextTick

process.nextTick is somewhat slow here and fixing it is tricky because on one hand you don't want it to be big because it gets pulled into a huge number of libraries but on the other hand libraries that a user has no control over (like streams) use it meaning that stand alone async modules (like immediate and asap) can't solve the problem.

While perf tests tend to emphasize the latency of the async function (I. E. the mutation observer or postMessage or setTimeout) in an actual app this will be a bottleneck when it is called recursively or many times at once. At these points the async function only needs to be called once and the queue ends up being the bottleneck.

It likely makes sense to get rid of most/all of the non setTimeout async functions and instead focus on making an efficient queue and point users needing low latency to things like asap and immediate.

When it comes to a queue for microtasks there are 3 approaches I've seen, the first is to use an array this is what's done here (and I used to do in immediate) the problem is that array.shift has some serious performance impacts.

Another used in asap and a lot of promise implementations that base their async on it quick is a circular buffer. This is fast but requires a circular buffer implementation which while not huge isn't nothing.

A third solution (which I use in immediate) is to grow the array, and drain it with a while loop, this avoids the overhead of shifting the element's and the size of a circular buffer, the trick is to swap out the in use buffer with a new one before draining it and then repeating for the new one until the new one has nothing in it after the drain. The swapping avoids a massive slowdown in cases when the queue gets long enough that the index is no longer a small int (which can cause an order of magnitude slowdown and memory usage). The swapping queue thing would also allow you to gage depth of recursive NextTick usage and give a warning like in node.

Thoughts?

New version breakage

Hello,

I'm not entirely sure if this is the right place to document this problem, but the latest version of process is breaking for us on the lines below.

// cached from whatever global is present so that test runners that stub it don't break things.
var cachedSetTimeout = setTimeout;
var cachedClearTimeout = clearTimeout;

Webpack includes process into the bundles it creates, and we execute the bundles on the client and on the server for rendering React components. For the server rendering there is no setTimeout, so the new code fails.

Do you think the problem is with process or with webpack?

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.