defunctzombie / node-process Goto Github PK
View Code? Open in Web Editor NEWprocess information for node.js and browsers
License: MIT License
process information for node.js and browsers
License: MIT License
we should probably set this to 'browser', thoughts ?
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!
I'm building an application with the following libraries:
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.
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.
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!
// cached from whatever global is present so that test runners that stub it don't break things.
var cachedSetTimeout = setTimeout;
var cachedClearTimeout = clearTimeout;
When browserifying a module that uses process
you'll get an Uncaught TypeError...
if this module uses stdout properties (see here)
From the Node.js documentation:
The
process
object is an instance ofEventEmitter
.
As such, it should stub all methods on the EventEmitter
API, in particular the listenerCount
method is missing.
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:
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).
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?
Missing from the API https://nodejs.org/api/process.html#process_process_uptime. Returns number of seconds since the process has been running.
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.
Discussed in this stack overflow post
When fetching this lib from npm, I get a bad gateway.
Is it possible to have an early implementation of process.stdout.write
with console.log()
?
What would be also awesome is process.stderr.write
≈ console.error
I am doing browserify of “pdf2png-mp” npm module with following steps:
<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
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()
looks like this was added in io.js 1.8.1 nodejs/node#1077
IE9 not work.
I'm having an issue on IE11 when calling process I get the error "Invalid Calling Object" in the method process.nextTick()
.
Would anyone be able to shed some light on this one? It's extremely difficult to debug in IE, but cachedSetTimeout
and drainQueue
are both defined.
I'm guessing it might be related to this? https://msdn.microsoft.com/en-us/library/gg622930(v=vs.85).aspx
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.
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
};
getting into an error using something experimental
it is throwing an error saying: process.emitWarning is not a function
I ran into issues as well as #37 and #38 and was wondering if we should switch to https://github.com/medikoo/next-tick?
It's a dedicated next-tick project with clear goals (in term of what to use as nextTick).
Thoughts?
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?
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
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:
drainQueue
starts the first time: queueIndex
is -1, queue
has one item in itdraining
is set to truesetTimeout(cleanUpNextTick)
calledcurrentQueue
is set to queue
, queue
is set to an empty arrayqueueIndex
compared to length of queue
and then incrementedcurrentQueue[queueIndex].run()
calledcleanUpNextTick
scheduled by drainQueue
draining
set to falsecleanUpNextTick
sets queue
to currentQueue
and calls drainQueue
, starting a second instance of drainQueue
currentQueue
set to a queue
(which is just what it was beforequeueIndex
is already 1
, no new functions are runqueueIndex
set to -1currentQueue
is set to nulldrainQueue
completesdrainQueue
regains controlqueueIndex
is -1, because of second drainQueue
queueIndex
is less than len
, so currentQueue[queueIndex].run()
is calledcurrentQueue
is nullI'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!
I understand your need to stay lean. You should mention this policy in the readme, and then maybe we can create a list of faithful shims the end user can add.
I published mine here https://github.com/kumavis/browser-process-hrtime
would you be open to a PR that attaches the messageEvent to an iframe instead (similar to http://dean.edwards.name/weblog/2006/11/sandbox/) or at least attempts to use stopImediatePropagation instead if it is available. Do you have a preferred method?
This project currently only supports commonJS, which is a bad news for my vite built project, so I tried to modify it myself to be compatible with es modules
https://github.com/kuankuan2007/node-process/tree/kuankuan2007
hi, process.stdout is missing. Would be really great to have a simple implementation for that!
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.
Would be great to have it implemented.
Many packages would run simply by having process.stdout.write()
(I'm using browserify).
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
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?
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
This is currently the fastest cross-environment way of creating a microtask. But more interestingly, it works in environments like the V8 shell where there is no setTimeout available to fall back to. (Why do I need browserify bundles to run inside the V8 shell you ask? MAD SCIENCE!)
(Originally browserify/browserify#1109)
A module that's using process.version.match(...)
fails in the browser because there's no process.version
on the shim. See browserify/browserify#690.
This is pretty easy to shim in few lines of code as seen by https://github.com/kumavis/browser-process-hrtime/blob/master/index.js . (And you can omit the browser prefixed versions.)
is it possible to copy global.process.versions so it can be used in Electronjs/Webpack 5 project
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.