diff --git a/build-scripts/vite.config.js b/build-scripts/vite.config.js index 51e35bb..0b8ee64 100644 --- a/build-scripts/vite.config.js +++ b/build-scripts/vite.config.js @@ -50,6 +50,7 @@ module.exports = defineConfig({ path.resolve(__dirname, '../client/js/entry-client-hydrogen.js'), path.resolve(__dirname, '../client/js/entry-client-room-directory.js'), path.resolve(__dirname, '../client/js/entry-client-room-alias-hash-redirect.js'), + path.resolve(__dirname, '../client/js/entry-client-timeout.js'), ], output: { assetFileNames: (chunkInfo) => { diff --git a/client/js/entry-client-timeout.js b/client/js/entry-client-timeout.js new file mode 100644 index 0000000..75ec846 --- /dev/null +++ b/client/js/entry-client-timeout.js @@ -0,0 +1,3 @@ +// Assets +import 'hydrogen-view-sdk/assets/theme-element-light.css'; +import '../css/styles.css'; diff --git a/server/hydrogen-render/render-page-html.js b/server/hydrogen-render/render-page-html.js index 62ec0a1..4135af2 100644 --- a/server/hydrogen-render/render-page-html.js +++ b/server/hydrogen-render/render-page-html.js @@ -8,7 +8,7 @@ const safeJson = require('../lib/safe-json'); const getDependenciesForEntryPointName = require('../lib/get-dependencies-for-entry-point-name'); const getFaviconAssetUrls = require('../lib/get-favicon-asset-urls'); -async function renderPageHtml({ +function renderPageHtml({ pageOptions, // Make sure you sanitize this before passing it to us bodyHtml, diff --git a/server/middleware/timeout-middleware.js b/server/middleware/timeout-middleware.js index 45dcd16..ce07468 100644 --- a/server/middleware/timeout-middleware.js +++ b/server/middleware/timeout-middleware.js @@ -5,7 +5,7 @@ const urlJoin = require('url-join'); const asyncHandler = require('../lib/express-async-handler'); const { getSerializableSpans, getActiveTraceId } = require('../tracing/tracing-middleware'); const sanitizeHtml = require('../lib/sanitize-html'); -const safeJson = require('../lib/safe-json'); +const renderPageHtml = require('../hydrogen-render/render-page-html'); const config = require('../lib/config'); const basePath = config.get('basePath'); @@ -19,7 +19,6 @@ async function timeoutMiddleware(req, res, next) { const timeoutId = setTimeout(() => { const traceId = getActiveTraceId(); const serializableSpans = getSerializableSpans(); - const serializedSpans = JSON.stringify(serializableSpans); let humanReadableSpans; if (serializableSpans.length > 0) { @@ -48,22 +47,9 @@ async function timeoutMiddleware(req, res, next) { humanReadableSpans = [noTracingDataAvailableItem]; } - const cspNonce = res.locals.cspNonce; - - const hydrogenStylesUrl = urlJoin(basePath, '/hydrogen-assets/hydrogen-styles.css'); - const stylesUrl = urlJoin(basePath, '/css/styles.css'); - - const pageHtml = ` - - -
- -Server was unable to respond in time (${requestTimeoutMs / 1000}s)
If there was a #room_alias:server hash in the URL, we tried redirecting you to the right place.
-- Otherwise, you're simply in a place that does not exist. - You can ${sanitizeHtml(`go back to the homepage.`)} -
- `; + ${/* We add the .hydrogen class here just to get normal body styles */ ''} +If there was a #room_alias:server hash in the URL, we tried redirecting you to the right place.
++ Otherwise, you're simply in a place that does not exist. + You can ${sanitizeHtml(`go back to the homepage.`)} +
+