Fix TypeError in strict mode - #86
Conversation
In strict mode, the following error will be thrown: "TypeError: Cannot set property path of #<IncomingMessage> which has only a getter", this should fix it.
|
this fix breaks polka (see travis) as req.path is used in handling requests for basenames |
@devcat I see. Will fix it asap. |
|
that doesn't fix it code requires |
Codecov Report
@@ Coverage Diff @@
## master #86 +/- ##
==========================================
- Coverage 100% 99.04% -0.96%
==========================================
Files 4 4
Lines 102 105 +3
==========================================
+ Hits 102 104 +2
- Misses 0 1 +1
Continue to review full report at Codecov.
|
@devcat Yeah, figured it out. Tests seem to pass now, will checkout for code coverage as well. |
lukeed
left a comment
There was a problem hiding this comment.
Ah, thanks. I don't use Polka in GCP functions because they have a lot of stuff built-in to the platform, so much of Polka (or anything) ends up being redundant.
The use of try/catch & Object.defineProperty is actually detrimental to the execution performance. 😕 Can you change it to my suggestion below? It should still work with the strict-mode getter.
if (!req.path) req.path = info.pathname;Thanks~!
|
@lukeed thanks for the sugestion, but unfortunately it doesn't pass the tests. What about removing the try/catch block and using this instead? |
|
Aye, my bad, that was an oversight. It won't update the It's I may have to rethink this a little bit. Does it work correctly within a GCP function with your original changes? |
|
Yeah, they're the same thing :) Cool – curious, but what's setting strict mode in the first place? |
|
@lukeed by inspecting the modules, seems that n_m/firebase-function, which takes my handler, uses strict mode. Haven’t found a way to disable it so far. |
|
Ah right, yeah. That would make sense. I'll play with this tonight, but again, I personally don't use Polka inside my GCP functions because it'd be pointless. Express is already "baked in" to the |
Using polka as a handler for firebase cloud functions will cause the following error to be thrown: "TypeError: Cannot set property path of # which has only a getter".
Basically, "strict mode" won't allow changing the request path since it got no setter implemented.
These changes fix it.