diff options
author | Leo Kettmeir <crowlkats@toaxl.com> | 2023-02-24 23:36:07 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-24 23:36:07 +0100 |
commit | 484b6fe2faeec93912e1fc57b54784428cbd15d3 (patch) | |
tree | 798ac60ce328a1f18204a31c06cf2f9ef2cbae82 /ext/flash/01_http.js | |
parent | 9aebc8bc19b1dfd9bce1789018f3f6b784175171 (diff) |
refactor(flash): move remoteAddr to options bag (#17913)
Applies suggestion from #17912
Diffstat (limited to 'ext/flash/01_http.js')
-rw-r--r-- | ext/flash/01_http.js | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/ext/flash/01_http.js b/ext/flash/01_http.js index 79a4963a5..267a3551c 100644 --- a/ext/flash/01_http.js +++ b/ext/flash/01_http.js @@ -579,16 +579,19 @@ function createServe(opFn) { ); let resp; + let remoteAddr; try { - resp = handler(req, () => { - const { 0: hostname, 1: port } = core.ops.op_flash_addr( - serverId, - i, - ); - return { - hostname, - port, - }; + resp = handler(req, { + get remoteAddr() { + if (!remoteAddr) { + const { 0: hostname, 1: port } = core.ops.op_flash_addr( + serverId, + i, + ); + remoteAddr = { hostname, port }; + } + return remoteAddr; + }, }); if (ObjectPrototypeIsPrototypeOf(PromisePrototype, resp)) { PromisePrototypeCatch( |