This repository has been archived by the owner on Jul 12, 2019. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Ok! So this fixes https://github.com/zapier/zapier/issues/26273. The root issue was that the early
require(appPath)
. Imagine you have the following:when you
require('./app')
,process.env.BASE_URL
is evaluated. The only problem is, theenv
being passed into lambda from the server isn't merged intoprocess.env
until this line, soapp.url
isundefined/oauth
. When it's required again as part ofloadApp
further down, the result is cached. So even thoughprocess.env.BASE_URL
exists, the url is wrong.I read carefully through everything the http patch does and moving it further into that method should have no ill effects (since nothing between its original and new position can use the
http
module). All the tests are passing as well. I also tested locally and the current env pops up as expected.I tried the following in
loadApp
, but weirdly, it didn't work. I had sunk enough time into this as is, so I didn't dig much further after confirming the fix itself.