Comments (15)
Hi! What environment are you looking to have a fallback in? Would you be willing to make a PR? If not a PR, then please let me know enough information so I can make the appropriate code :)
from nodejs-depd.
As per #14, in Firefox it throws this error:
TypeError: Error.captureStackTrace is not a function
I will gladly make a PR, but wasn't sure exactly what I should be checking against. Is it sufficient just to check for Error.captureStackTrace
?
I am yet to come across an environment which doesn't have a stack
property on error objects. Is there any reason why we can't just use this? I am assuming that the (V8 specific?) Error.prepareStackTrace
, Error.captureStackTrace
, Error.stackTraceLimit
are as some kind of performance optimisation?
from nodejs-depd.
Hi! Can you say an exact version of Firefox I need to target as well? For example, do I need to ensure it worked on Firefox 3.5 or is some other version more appropriate?
The stack property is a string. Different environments format their string differently and the format is not standard. This means you're just going to have the same incompatibilities with the stack property.
We actually interrogate the stack at a level that the stack string just really does not work. The stack string also makes it virtually impossible to use if a file name contains a new line character (yes, file names can contain a new line, so you cannot just split the stack on "\n").
I hope that helps explain why this module can not use the string stack property.
from nodejs-depd.
Oh, and yet another issue is that the .stack property only contains a portion of the stack. This means if what we are looking for is too far on the stack, it won't even be contained in the .stack property.
Essentially this module just cannot function at all without the V8 stack functions (or something similar). What makes this module great is that it will include the exact callsite of the usage in your code on warning, it will not warn on even usage (think about a webserver that uses a deprecated method for a request--that would mean one message per request!), it will also ensure that you are warned for each unique usage in your code, not just stop warning after the first use. This allows people to run a test suite once and get all the warning they need to fix, not run once, get one warning, fix, run again, get second warning, fix, etc.
from nodejs-depd.
2.It's not my module's responsibility - depd does non-standard things, not me
Also, on this point, it actually is not our responsibility, as you can see from the package.json, we have clearly outlined out supported environments. Our contract with users is this code is only to be used in Node.js 0.6+; any other use is at you own risk.
from nodejs-depd.
Also, it may be useful another user attempted this before in #15 but after they dug into the code, abandoned the PR. Just pointing you to the PR so essentially you can read it and pick up where it was left off :)
from nodejs-depd.
I'm using Firefox 35.0, any reasonably recent version would be fine.
Yes I love the single-warning and proper callsite, it makes my life so much easier :)
Thanks for the info on .stack
, that's worth knowing. I guess we just need to check for the availability of V8 functions then.
from nodejs-depd.
Hi @SystemParadox , I'm looking into this, and have another question for you: how are you getting this code into the web browser in the first place? Are you just copy-pasting the code, or using a system like browserify or webpack (and if so, which one specifically)?
from nodejs-depd.
from nodejs-depd.
Awesome, thanks, @SystemParadox ! So what I'm going to do for now, while #16 is underway, is get this module to just work in a "noop" mode when in the browser. I was thinking of doing this simply with package.json
tweak for now, which would work with browserify/webpack. I think that this will get modules using this one to work in the meantime, while I work on replicating as much functionality as I can for web browsers, at which time those module can take advantage of when it's released.
How does that sound :) ?
from nodejs-depd.
Ok, master
has been updated to add a different branch (for now) when bundling with Browserify for the web environment. Let me know if it works for you and I'll release it out there :)
from nodejs-depd.
Hi @SystemParadox , any feedback on the current master
implementation?
from nodejs-depd.
Sorry I'm away at the moment, will have a look at this next week.
from nodejs-depd.
I can remove my shim and it still runs in Firefox :)
However, in the longer term I don't think you need to use a package.json shim. Just check for the availability of the V8-specific APIs (Error.captureStackTrace, etc) before you use them. If they are not available, then noop or fallback to alternative implementation. It worked fine in Chrome before, by using a package.json shim we've lost that.
from nodejs-depd.
I understand and this is only the short-term fix so that people's packages run in Firefox at all. I am working on a more robust one.
from nodejs-depd.
Related Issues (20)
- Stack trace api differences when in strict mode causing TypeErrors HOT 25
- Drop eval usage HOT 21
- line info is not help HOT 8
- Cannot redefine property: callSiteToString HOT 2
- Call-site calculation does not fail gracefully when Stack information is unavailable HOT 14
- Call site calculation fails when importing an esm'ed package that imports sequelize internally HOT 14
- Respect --no-deprecation and process.noDeprecation HOT 17
- TypeError: eval is not a function HOT 8
- Why is this library overwriting Error type? HOT 5
- Turkish Language Problem HOT 2
- Incopatibile with --enable-source-maps node 12 option HOT 7
- (!) Use of eval is strongly discouraged, rollup HOT 1
- compatibility with Node.js' source-map implementation HOT 12
- please rewrite nodejs-depd with modern syntax HOT 1
- Compatibility with --disallow-code-generation-from-strings HOT 9
- Use of eval() is strongly discouraged, as it poses security risks HOT 9
- Calling `process.cwd()` from index.js can be problematic HOT 4
- callSite.getFileName() is not Function HOT 5
- `callSite.getFileName` is not a function HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nodejs-depd.