Would work for most but my stuff requires additional modules dynamically as
it runs, to avoid polluting startup with things that may never be needed
(like dev/test/maintenance functions). So, I'd need to restore the Sync
functions temporarily for require. Looks like it can be done by wrapping
the require hooks.
The bottom line is that require should not be sync. It does not work well
if you require modules dynamically, it also makes it harder to hack require
so that it loads code from something else than the local file system (a
database or a RESTful service). But it is probably too late to do anything
about it.
Bruno
On Thursday, April 19, 2012 11:12:41 PM UTC+2, Axel Kittenberger wrote:
>
> > Would it be possible to have a "strict async" switch that make all Sync
> > calls throw if called outside of startup or require sequences?
> > This would make it easy to spot libraries that are potential perf
> killers.
>
> I'm not sure how the node modules system behaves if you alter required
> tables, so would this work*?
>
> var gotyou = function() { throw new Error('Evil Sync caller you!'); };
> for (var k in fs) {
> if (fs.hasOwnProperty(k) && k.search(/Sync$/) >= 0) { fs[k] = gotyou; }
> }
>
> *Unless something is that evil to cache the function pointers, or to
> require later on. However, one could set "require" to gotyou as well
> after startup.
>
>
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en