Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 1 addition & 18 deletions src/core/server/http/lifecycle/on_pre_routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,24 +102,7 @@ export function adoptToHapiOnRequest(fn: OnPreRoutingHandler, log: Logger) {
appState.rewrittenUrl = appState.rewrittenUrl ?? request.url;

const { url } = result;

// TODO: Remove once we upgrade to Node.js 12!
Copy link
Copy Markdown
Contributor Author

@mshustov mshustov Jun 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added by @watson during #80713 to fix a CI failure

//
// Warning: The following for-loop took 10 days to write, and is a hack
// to force V8 to make a copy of the string in memory.
//
// The reason why we need this is because of what appears to be a bug
// in V8 that caused some URL paths to not be routed correctly once
// `request.setUrl` was called with the path.
//
// The details can be seen in this discussion on Twitter:
// https://twitter.com/wa7son/status/1319992632366518277
let urlCopy = '';
for (let i = 0; i < url.length; i++) {
urlCopy += url[i];
}
Comment on lines -117 to -120
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm gonna show you what's called a pro-gamer move.


request.setUrl(urlCopy);
request.setUrl(url);

// We should update raw request as well since it can be proxied to the old platform
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should remove it as well

request.raw.req.url = url;
Expand Down