diff --git a/keyserver/src/responders/landing-handler.js b/keyserver/src/responders/landing-handler.js --- a/keyserver/src/responders/landing-handler.js +++ b/keyserver/src/responders/landing-handler.js @@ -229,16 +229,21 @@ // We remove trailing slash for `react-router` const routerBasename = basePath.replace(/\/$/, ''); const clientPath = routerBasename + req.url; - await new Promise((resolve, reject) => { - const { - pipe, - }: { - +pipe: ( - destination: $Response, - options?: { +end?: boolean, ... }, - ) => void, - ... - } = renderToPipeableStream( + + const siweNonceString = siweNonce ? `"${siweNonce}"` : 'null'; + const siwePrimaryIdentityPublicKeyString = siwePrimaryIdentityPublicKey + ? `"${siwePrimaryIdentityPublicKey}"` + : 'null'; + const siweMessageTypeString = siweMessageType + ? `"${siweMessageType}"` + : 'null'; + const siweMessageIssuedAtString = siweMessageIssuedAt + ? `"${siweMessageIssuedAt}"` + : 'null'; + + await new Promise((resolve, reject) => { + let didError = false; + const reactStream = renderToPipeableStream( , { - onShellReady() { - pipe(res, { end: false }); - }, onAllReady() { + reactStream.pipe(res, { end: false }); + res.statusCode = didError ? 500 : 200; + + // prettier-ignore + res.end(html` + + + + + + + + + `); + + console.log('Stream done'); resolve(); }, - onError(error) { - reject(error); + onError(x) { + didError = true; + console.error('Stream error', x); + reject(x); }, }, ); }); - - const siweNonceString = siweNonce ? `"${siweNonce}"` : 'null'; - const siwePrimaryIdentityPublicKeyString = siwePrimaryIdentityPublicKey - ? `"${siwePrimaryIdentityPublicKey}"` - : 'null'; - const siweMessageTypeString = siweMessageType - ? `"${siweMessageType}"` - : 'null'; - const siweMessageIssuedAtString = siweMessageIssuedAt - ? `"${siweMessageIssuedAt}"` - : 'null'; - // prettier-ignore - res.end(html` - - - - - - - - - `); } export default landingHandler; diff --git a/keyserver/src/responders/website-responders.js b/keyserver/src/responders/website-responders.js --- a/keyserver/src/responders/website-responders.js +++ b/keyserver/src/responders/website-responders.js @@ -179,41 +179,41 @@ `); const Loading = await loadingPromise; - await new Promise((resolve, reject) => { - const { - pipe, - }: { - +pipe: ( - destination: $Response, - options?: { +end?: boolean, ... }, - ) => void, - ... - } = renderToPipeableStream(, { - onShellReady() { - pipe(res, { end: false }); - }, + + await new Promise((resolve, reject) => { + let didError = false; + const reactStream = renderToPipeableStream(, { onAllReady() { + reactStream.pipe(res); + res.statusCode = didError ? 500 : 200; + + // prettier-ignore + res.end(html` + + + + + + `); + console.log('Stream done'); resolve(); }, - onError(error) { - reject(error); + onError(x) { + didError = true; + console.error('Stream error', x); + reject(x); }, }); }); - res.end(html` - - - - - - `); + + // await waitForStream(reactStream); } // On native, if this responder is called, it means that the app isn't diff --git a/yarn.lock b/yarn.lock --- a/yarn.lock +++ b/yarn.lock @@ -21227,14 +21227,6 @@ dnd-core "^11.1.3" hoist-non-react-statics "^3.3.0" -react-dom@18.1.0: - version "18.1.0" - resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-18.1.0.tgz#7f6dd84b706408adde05e1df575b3a024d7e8a2f" - integrity sha512-fU1Txz7Budmvamp7bshe4Zi32d0ll7ect+ccxNu9FlObT605GOEB8BfO4tmRJ39R5Zj831VCpvQ05QPBW5yb+w== - dependencies: - loose-envify "^1.1.0" - scheduler "^0.22.0" - react-dom@19.1.0: version "19.1.0" resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-19.1.0.tgz#133558deca37fa1d682708df8904b25186793623" @@ -21755,13 +21747,6 @@ "@babel/runtime" "^7.0.0" memoize-one ">=3.1.1 <6" -react@18.1.0: - version "18.1.0" - resolved "https://registry.yarnpkg.com/react/-/react-18.1.0.tgz#6f8620382decb17fdc5cc223a115e2adbf104890" - integrity sha512-4oL8ivCz5ZEPyclFQXaNksK3adutVS8l2xzZU0cqEFrE9Sb7fC0EFK5uEk74wIreL1DERyjvsU915j1pcT2uEQ== - dependencies: - loose-envify "^1.1.0" - react@19.1.0: version "19.1.0" resolved "https://registry.yarnpkg.com/react/-/react-19.1.0.tgz#926864b6c48da7627f004795d6cce50e90793b75"