-
-
Notifications
You must be signed in to change notification settings - Fork 17.1k
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
Cannot read property 'encrypted' of undefined #2994
Comments
Hi @cressie176 -- you are correct, during the stringify of process it attempts to stringify Some of these properties rely on certain values being non-null -- evaluating them outside the context of an application/active connection means some of these values are I just hacked my local express to include null-checks around the problematic property getters and it is possible to make it work. Does the @expressjs/express-tc have an opinion on whether we should add null-checks for these property getters? |
What is the use case for stringifying |
Also, wondering if this can be considered a valid issue in Express, at all. |
It seems like |
I don't think this is a big in Express, and I don't think we should add a bunch of null check on everything (what would we do if it was null? Return null? How would we document under what conditions those will be null? What is the user expected to do when they return null? How will we know or users know about bugs if everything just silently returns null when fundamental object assumptions are not true?). The issue here is that the user is trying to read properties on our export of a prototype. If those exports are not documented, that is a separate issue and they should be, as they are useful to add new global getters/setters, and also make Express behave better with the htttp2 module. As for when it is valid to access the properties, the answer is that object represents a prototype, so the only time is though a concrete object that has that prototype in it's chain. Maybe there is a better solution somewhere to this, but I don't think null checks is the right solution. |
I would ask why happens if someone does
with Express loaded? If it does not die, then maybe there is a bug in "json-stringify-safe"? It would sound less safe than standard JSON stringify if this is the case. |
@dougwilson I gave |
Gotcha. This issue does not seem specific to Express, so I'm not sure changing anything here makes sense. For example, you can try various modules and you'll run into various errors all over the place, because no module expects that it's For example, here is
|
For some reason I haven't been getting notifications for this otherwise I would have responded. I'd incorrectly assumed express intentionally was modifying the process for some reason, and hadn't realised the recursion into process.mainModule was the cause. Thanks for investigating. |
Simply requiring express then attempting to safe stringify process causes an exception.
Result
The text was updated successfully, but these errors were encountered: