From 9b47e4729ed61793357ad7174d233e81c336b6c1 Mon Sep 17 00:00:00 2001 From: VeenaYemmiganur Date: Mon, 27 Oct 2025 11:29:00 +0530 Subject: [PATCH 01/11] debug. 500 issue --- server/handlers/isomorphic-handler.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/server/handlers/isomorphic-handler.js b/server/handlers/isomorphic-handler.js index db6e4d12..0c72a8ae 100644 --- a/server/handlers/isomorphic-handler.js +++ b/server/handlers/isomorphic-handler.js @@ -125,7 +125,7 @@ function loadDataForPageType( .then((result) => { if (result && result.data) { if (result.data[ABORT_HANDLER] || (result.data.error && result.data.error.message)) { - return null + return null; } } return result; @@ -485,6 +485,12 @@ exports.handleIsomorphicRoute = function handleIsomorphicRoute( }); return res.redirect(301, result.data.location); } + + if (statusCode == 500) { + console.log("RESULT 111 =============>>>", statusCode); + return res.sendStatus(500); + } + const seoInstance = getSeoInstance(seo, config, result.pageType); const seoTags = seoInstance && seoInstance.getMetaTags(config, result.pageType || match.pageType, result, { url }); From 61e89c43ed411994fcf47992d5a5a117b3897c81 Mon Sep 17 00:00:00 2001 From: VeenaYemmiganur Date: Mon, 27 Oct 2025 16:19:20 +0530 Subject: [PATCH 02/11] dummy commit: debug status 500 --- test/integration/isomorphic-handler-test.js | 51 ++++++++++----------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/test/integration/isomorphic-handler-test.js b/test/integration/isomorphic-handler-test.js index 6acbea94..fc20fd55 100644 --- a/test/integration/isomorphic-handler-test.js +++ b/test/integration/isomorphic-handler-test.js @@ -154,32 +154,31 @@ describe("Isomorphic Handler", function () { .then(done); }); - it("Throws a 500 if loadData doesn't work", function (done) { - const app = createApp( - (pageType, params, config, client) => { - throw "exception"; - }, - [{ pageType: "home-page", path: "/" }], - { - loadErrorData: (err, config) => ({ - httpStatusCode: err.httpStatusCode || 500, - pageType: "not-found", - data: { text: "foobar" }, - }), - } - ); - - supertest(app) - .get("/") - .expect("Content-Type", /html/) - .expect(500) - .then((res) => { - const response = JSON.parse(res.text); - assert.equal('
foobar
', response.content); - assert.equal(true, response.store.qt.disableIsomorphicComponent); - }) - .then(done, done); - }); + // it("Throws a 500 if loadData doesn't work", function (done) { + // const app = createApp( + // (pageType, params, config, client) => { + // throw "exception"; + // }, + // [{ pageType: "home-page", path: "/" }], + // { + // loadErrorData: (err, config) => ({ + // httpStatusCode: err.httpStatusCode || 500, + // pageType: "not-found", + // data: { text: "foobar" }, + // }), + // } + // ); + // supertest(app) + // .get("/") + // .expect("Content-Type", /html/) + // .expect(500) + // .then((res) => { + // const response = JSON.parse(res.text); + // assert.equal('
foobar
', response.content); + // assert.equal(true, response.store.qt.disableIsomorphicComponent); + // }) + // .then(done, done); + // }); it("Throws a 500 if loadData and loadErrorData both crash", function (done) { const app = createApp( From 422818733d5fdd1a05d19ca7093e028481dbe07b Mon Sep 17 00:00:00 2001 From: VeenaYemmiganur Date: Mon, 27 Oct 2025 16:20:08 +0530 Subject: [PATCH 03/11] chore(release): 7.34.7-handle-500-issue.0 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index f729e093..f2b9e67e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@quintype/framework", - "version": "7.34.6", + "version": "7.34.7-handle-500-issue.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@quintype/framework", - "version": "7.34.6", + "version": "7.34.7-handle-500-issue.0", "license": "ISC", "dependencies": { "@ampproject/toolbox-optimizer": "2.8.3", diff --git a/package.json b/package.json index 73ea842f..695624cb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@quintype/framework", - "version": "7.34.6", + "version": "7.34.7-handle-500-issue.0", "description": "Libraries to help build Quintype Node.js apps", "main": "index.js", "engines": { From c3d92b48a9ae257a93874322287b6b1eac018ea8 Mon Sep 17 00:00:00 2001 From: VeenaYemmiganur Date: Tue, 28 Oct 2025 16:19:57 +0530 Subject: [PATCH 04/11] commit: debug status 500 --- server/handlers/isomorphic-handler.js | 8 ++-- test/integration/isomorphic-handler-test.js | 43 ++++++++------------- 2 files changed, 22 insertions(+), 29 deletions(-) diff --git a/server/handlers/isomorphic-handler.js b/server/handlers/isomorphic-handler.js index 0c72a8ae..7045b8ba 100644 --- a/server/handlers/isomorphic-handler.js +++ b/server/handlers/isomorphic-handler.js @@ -486,9 +486,11 @@ exports.handleIsomorphicRoute = function handleIsomorphicRoute( return res.redirect(301, result.data.location); } - if (statusCode == 500) { - console.log("RESULT 111 =============>>>", statusCode); - return res.sendStatus(500); + // For server errors (>=500),send statuss + if (statusCode >= 500) { + res.status(statusCode); + res.setHeader("Content-Type", "text/html; charset=utf-8"); + return res.sendStatus(statusCode); } const seoInstance = getSeoInstance(seo, config, result.pageType); diff --git a/test/integration/isomorphic-handler-test.js b/test/integration/isomorphic-handler-test.js index fc20fd55..f0950672 100644 --- a/test/integration/isomorphic-handler-test.js +++ b/test/integration/isomorphic-handler-test.js @@ -154,31 +154,22 @@ describe("Isomorphic Handler", function () { .then(done); }); - // it("Throws a 500 if loadData doesn't work", function (done) { - // const app = createApp( - // (pageType, params, config, client) => { - // throw "exception"; - // }, - // [{ pageType: "home-page", path: "/" }], - // { - // loadErrorData: (err, config) => ({ - // httpStatusCode: err.httpStatusCode || 500, - // pageType: "not-found", - // data: { text: "foobar" }, - // }), - // } - // ); - // supertest(app) - // .get("/") - // .expect("Content-Type", /html/) - // .expect(500) - // .then((res) => { - // const response = JSON.parse(res.text); - // assert.equal('
foobar
', response.content); - // assert.equal(true, response.store.qt.disableIsomorphicComponent); - // }) - // .then(done, done); - // }); + it("Throws a 500 if loadData doesn't work", function (done) { + const app = createApp( + (pageType, params, config, client) => { + throw "exception"; + }, + [{ pageType: "home-page", path: "/" }], + { + loadErrorData: (err, config) => ({ + httpStatusCode: err.httpStatusCode || 500, + pageType: "not-found", + data: { text: "foobar" }, + }), + } + ); + supertest(app).get("/").expect(500, done); + }); it("Throws a 500 if loadData and loadErrorData both crash", function (done) { const app = createApp( @@ -193,7 +184,7 @@ describe("Isomorphic Handler", function () { } ); - supertest(app).get("/").expect("Content-Type", /html/).expect(500, done); + supertest(app).get("/").expect(500, done); }); it("Cache headers are set", function (done) { From 13a2a12f4b1fa95091b2c98d870e4639a5bf169e Mon Sep 17 00:00:00 2001 From: VeenaYemmiganur Date: Tue, 28 Oct 2025 16:20:35 +0530 Subject: [PATCH 05/11] chore(release): 7.34.7-handle-500-issue.1 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index f2b9e67e..c69e6107 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@quintype/framework", - "version": "7.34.7-handle-500-issue.0", + "version": "7.34.7-handle-500-issue.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@quintype/framework", - "version": "7.34.7-handle-500-issue.0", + "version": "7.34.7-handle-500-issue.1", "license": "ISC", "dependencies": { "@ampproject/toolbox-optimizer": "2.8.3", diff --git a/package.json b/package.json index 695624cb..33112020 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@quintype/framework", - "version": "7.34.7-handle-500-issue.0", + "version": "7.34.7-handle-500-issue.1", "description": "Libraries to help build Quintype Node.js apps", "main": "index.js", "engines": { From e632113a37f1e86bc77077f654f643614b287d0c Mon Sep 17 00:00:00 2001 From: VeenaYemmiganur Date: Thu, 30 Oct 2025 15:01:30 +0530 Subject: [PATCH 06/11] dummy commit.testing caching --- constants.js | 2 +- server/handlers/cdn-caching.js | 2 +- server/handlers/isomorphic-handler.js | 2 -- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/constants.js b/constants.js index c0ec01a4..bfa2fa53 100644 --- a/constants.js +++ b/constants.js @@ -1,3 +1,3 @@ -const STALE_IF_ERROR_CACHE_DURATION = 14400; +const STALE_IF_ERROR_CACHE_DURATION = 120; module.exports = { STALE_IF_ERROR_CACHE_DURATION }; diff --git a/server/handlers/cdn-caching.js b/server/handlers/cdn-caching.js index 34c94db9..031eba69 100644 --- a/server/handlers/cdn-caching.js +++ b/server/handlers/cdn-caching.js @@ -42,7 +42,7 @@ exports.addCacheHeadersToResult = function addCacheHeadersToResult({ } else { res.setHeader( "Cache-Control", - `public,max-age=${maxAge},s-maxage=${sMaxAge},stale-while-revalidate=1000,stale-if-error=${STALE_IF_ERROR_CACHE_DURATION}` + `public,max-age=${maxAge},s-maxage=${sMaxAge},stale-while-revalidate=120,stale-if-error=${STALE_IF_ERROR_CACHE_DURATION}` ); } diff --git a/server/handlers/isomorphic-handler.js b/server/handlers/isomorphic-handler.js index 7045b8ba..6b6ae0fa 100644 --- a/server/handlers/isomorphic-handler.js +++ b/server/handlers/isomorphic-handler.js @@ -488,8 +488,6 @@ exports.handleIsomorphicRoute = function handleIsomorphicRoute( // For server errors (>=500),send statuss if (statusCode >= 500) { - res.status(statusCode); - res.setHeader("Content-Type", "text/html; charset=utf-8"); return res.sendStatus(statusCode); } From 266acbd4fde9ba616c9e3f3beb5c52b1bc1e8e21 Mon Sep 17 00:00:00 2001 From: VeenaYemmiganur Date: Thu, 30 Oct 2025 15:22:42 +0530 Subject: [PATCH 07/11] dummy commit. changed all cache windows to 2 min --- constants.js | 2 +- server/handlers/cdn-caching.js | 2 +- test/integration/custom-route-handler-test.js | 57 +++++-------------- test/integration/isomorphic-handler-test.js | 15 ++--- test/integration/url-redirect-test.js | 50 ++++------------ 5 files changed, 31 insertions(+), 95 deletions(-) diff --git a/constants.js b/constants.js index bfa2fa53..c0ec01a4 100644 --- a/constants.js +++ b/constants.js @@ -1,3 +1,3 @@ -const STALE_IF_ERROR_CACHE_DURATION = 120; +const STALE_IF_ERROR_CACHE_DURATION = 14400; module.exports = { STALE_IF_ERROR_CACHE_DURATION }; diff --git a/server/handlers/cdn-caching.js b/server/handlers/cdn-caching.js index 031eba69..027978d2 100644 --- a/server/handlers/cdn-caching.js +++ b/server/handlers/cdn-caching.js @@ -42,7 +42,7 @@ exports.addCacheHeadersToResult = function addCacheHeadersToResult({ } else { res.setHeader( "Cache-Control", - `public,max-age=${maxAge},s-maxage=${sMaxAge},stale-while-revalidate=120,stale-if-error=${STALE_IF_ERROR_CACHE_DURATION}` + `public,max-age=${maxAge},s-maxage=120,stale-while-revalidate=120,stale-if-error=120` ); } diff --git a/test/integration/custom-route-handler-test.js b/test/integration/custom-route-handler-test.js index a0eaef03..bffeaf52 100644 --- a/test/integration/custom-route-handler-test.js +++ b/test/integration/custom-route-handler-test.js @@ -48,8 +48,7 @@ function getClientStub(hostname) { page: { id: 103, title: "Testing", - content: - "Test

Heading

", + content: "Test

Heading

", metadata: { header: true, footer: false }, type: "static-page", "status-code": 200, @@ -60,8 +59,7 @@ function getClientStub(hostname) { page: { id: 104, title: "Testing", - content: - "Test

Heading

", + content: "Test

Heading

", metadata: { header: false, footer: false }, type: "static-page", "status-code": 200, @@ -72,8 +70,7 @@ function getClientStub(hostname) { page: { id: 105, title: "Testing mime type", - content: - "Test

Heading

", + content: "Test

Heading

", metadata: { header: false, footer: false, @@ -104,9 +101,7 @@ function createApp(loadData, routes, opts = {}) { generateRoutes: () => routes, loadData, renderLayout: (res, { contentTemplate, store }) => - res.send( - JSON.stringify({ contentTemplate, store: store.getState() }) - ), + res.send(JSON.stringify({ contentTemplate, store: store.getState() })), handleNotFound: false, publisherConfig: {}, }, @@ -126,10 +121,7 @@ describe("Custom Route Handler", function () { supertest(app) .get("/moved-permanently") .expect("Location", "/permanent-location") - .expect( - "Cache-Control", - "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400" - ) + .expect("Cache-Control", "public,max-age=15,s-maxage=120,stale-while-revalidate=120,stale-if-error=120") .expect("Vary", /Accept\-Encoding/) .expect("Surrogate-Key", "sp/42/101") .expect("Cache-Tag", "sp/42/101") @@ -144,10 +136,7 @@ describe("Custom Route Handler", function () { supertest(app) .get("/moved-temporarily") .expect("Location", "/temporary-location") - .expect( - "Cache-Control", - "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400" - ) + .expect("Cache-Control", "public,max-age=15,s-maxage=120,stale-while-revalidate=120,stale-if-error=120") .expect("Vary", /Accept\-Encoding/) .expect("Surrogate-Key", "sp/42/102") .expect("Cache-Tag", "sp/42/102") @@ -163,10 +152,7 @@ describe("Custom Route Handler", function () { supertest(app) .get("/static-with-header-footer") .expect("Content-Type", /html/) - .expect( - "Cache-Control", - "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400" - ) + .expect("Cache-Control", "public,max-age=15,s-maxage=120,stale-while-revalidate=120,stale-if-error=120") .expect("Vary", "Accept-Encoding") .expect("Surrogate-Key", "sp/42/103") .expect("Cache-Tag", "sp/42/103") @@ -188,19 +174,13 @@ describe("Custom Route Handler", function () { supertest(app) .get("/static-without-header-footer") .expect("Content-Type", /html/) - .expect( - "Cache-Control", - "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400" - ) + .expect("Cache-Control", "public,max-age=15,s-maxage=120,stale-while-revalidate=120,stale-if-error=120") .expect("Vary", "Accept-Encoding") .expect("Surrogate-Key", "sp/42/104") .expect("Cache-Tag", "sp/42/104") .expect(200) .then((res) => { - assert.equal( - "Test

Heading

", - res.text - ); + assert.equal("Test

Heading

", res.text); }) .then(done); }); @@ -233,9 +213,7 @@ describe("Custom Route Handler", function () { it("Store reads config and data from data-loader response", function (done) { const app = createApp( (pageType, params, config, client, { host, next }) => - pageType === "custom-static-page" - ? Promise.resolve({ data: { navigationMenu: [] }, config: {} }) - : next(), + pageType === "custom-static-page" ? Promise.resolve({ data: { navigationMenu: [] }, config: {} }) : next(), [{ pageType: "story-page", path: "/*" }] ); supertest(app) @@ -258,10 +236,7 @@ describe("Custom Route Handler", function () { supertest(app) .get("/moved-absolute") .expect("Location", "https://www.google.com") - .expect( - "Cache-Control", - "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400" - ) + .expect("Cache-Control", "public,max-age=15,s-maxage=120,stale-while-revalidate=120,stale-if-error=120") .expect("Vary", /Accept\-Encoding/) .expect("Surrogate-Key", "sp/42/105") .expect("Cache-Tag", "sp/42/105") @@ -275,10 +250,7 @@ describe("Custom Route Handler", function () { ); supertest(app) .get("/static-with-mime-type") - .expect( - "Cache-Control", - "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400" - ) + .expect("Cache-Control", "public,max-age=15,s-maxage=120,stale-while-revalidate=120,stale-if-error=120") .expect("Vary", /Accept\-Encoding/) .expect("Surrogate-Key", "sp/42/105") .expect("Cache-Tag", "sp/42/105") @@ -293,10 +265,7 @@ describe("Custom Route Handler", function () { ); supertest(app) .get("/static-without-header-footer") - .expect( - "Cache-Control", - "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400" - ) + .expect("Cache-Control", "public,max-age=15,s-maxage=120,stale-while-revalidate=120,stale-if-error=120") .expect("Vary", "Accept-Encoding") .expect("Surrogate-Key", "sp/42/104") .expect("Cache-Tag", "sp/42/104") diff --git a/test/integration/isomorphic-handler-test.js b/test/integration/isomorphic-handler-test.js index f0950672..a6536f14 100644 --- a/test/integration/isomorphic-handler-test.js +++ b/test/integration/isomorphic-handler-test.js @@ -200,7 +200,7 @@ describe("Isomorphic Handler", function () { supertest(app) .get("/") .expect("Content-Type", /html/) - .expect("Cache-Control", "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400") + .expect("Cache-Control", "public,max-age=15,s-maxage=120,stale-while-revalidate=120,stale-if-error=120") .expect("Vary", "Accept-Encoding") .expect("Surrogate-Key", "foo bar") .expect("Cache-Tag", "foo,bar") @@ -503,7 +503,7 @@ describe("Isomorphic Handler", function () { .then((res) => { const cacheControl = res.header["cache-control"]; const cacheTag = res.header["cache-tag"]; - assert.equal(cacheControl, "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400"); + assert.equal(cacheControl, "public,max-age=15,s-maxage=120,stale-while-revalidate=120,stale-if-error=120"); assert.equal(cacheTag, "c/1/abcdefgh"); }) .then(done); @@ -631,7 +631,7 @@ describe("Isomorphic Handler", function () { const cacheControl = res.header["cache-control"]; const edgeCacheTag = res.header["edge-cache-tag"]; const contentSecurityPolicy = res.header["content-security-policy"]; - assert.equal(cacheControl, "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400"); + assert.equal(cacheControl, "public,max-age=15,s-maxage=120,stale-while-revalidate=120,stale-if-error=120"); assert.equal(edgeCacheTag, "c/1/abcdefgh"); assert.equal( contentSecurityPolicy, @@ -670,7 +670,7 @@ describe("Isomorphic Handler", function () { const cacheControl = res.header["cache-control"]; const edgeCacheTag = res.header["edge-cache-tag"]; const contentSecurityPolicy = res.header["content-security-policy"]; - assert.equal(cacheControl, "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400"); + assert.equal(cacheControl, "public,max-age=15,s-maxage=120,stale-while-revalidate=120,stale-if-error=120"); assert.equal(edgeCacheTag, "c/1/abcdefgh"); assert.equal( contentSecurityPolicy, @@ -706,10 +706,7 @@ describe("Isomorphic Handler", function () { .expect(200) .then((res) => { const cacheControl = res.header["cache-control"]; - assert.equal( - cacheControl, - "public,max-age=15,s-maxage=1800,stale-while-revalidate=1000,stale-if-error=14400" - ); + assert.equal(cacheControl, "public,max-age=15,s-maxage=120,stale-while-revalidate=120,stale-if-error=120"); }) .then(done); }); @@ -730,7 +727,7 @@ describe("Isomorphic Handler", function () { .expect(200) .then((res) => { const cacheControl = res.header["cache-control"]; - assert.equal(cacheControl, "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400"); + assert.equal(cacheControl, "public,max-age=15,s-maxage=120,stale-while-revalidate=120,stale-if-error=120"); }) .then(done); }); diff --git a/test/integration/url-redirect-test.js b/test/integration/url-redirect-test.js index 8ca1b0f6..1ee791f4 100644 --- a/test/integration/url-redirect-test.js +++ b/test/integration/url-redirect-test.js @@ -508,10 +508,7 @@ describe("Redirect Routes Handler", function () { redirectUrls, } ); - supertest(app) - .get("/moved-permanently-1") - .expect("Location", "/permanent-location-1") - .expect(301, done); + supertest(app).get("/moved-permanently-1").expect("Location", "/permanent-location-1").expect(301, done); }); it("Redirects all the urls with status code to 302 if redirectUrls is present", function (done) { @@ -528,10 +525,7 @@ describe("Redirect Routes Handler", function () { ], } ); - supertest(app) - .get("/moved-temporarily-1") - .expect("Location", "/temporarily-location-1") - .expect(302, done); + supertest(app).get("/moved-temporarily-1").expect("Location", "/temporarily-location-1").expect(302, done); }); it("Renders homepage when redirect urls are present", function (done) { @@ -555,10 +549,7 @@ describe("Redirect Routes Handler", function () { .expect(200) .then((res) => { const response = JSON.parse(res.text); - assert.equal( - '
foobar
', - response.content - ); + assert.equal('
foobar
', response.content); assert.equal("foobar", response.store.qt.data.text); assert.equal("127.0.0.1", response.store.qt.data.host); assert.equal("home-page", response.store.qt.pageType); @@ -572,10 +563,7 @@ describe("Redirect Routes Handler", function () { [{ pageType: "story-page", path: "/*" }], { redirectUrls: getRedirectUrl } ); - supertest(app) - .get("/moved-permanently-1") - .expect("Location", "/permanent-location-1") - .expect(301, done); + supertest(app).get("/moved-permanently-1").expect("Location", "/permanent-location-1").expect(301, done); }); it("Should handle Route Parameters redirects properly", function (done) { @@ -584,10 +572,7 @@ describe("Redirect Routes Handler", function () { [{ pageType: "story-page", path: "/*" }], { redirectUrls: getRedirectUrl } ); - supertest(app) - .get("/india/news/some-slug") - .expect("Location", "/india/some-slug") - .expect(301, done); + supertest(app).get("/india/news/some-slug").expect("Location", "/india/some-slug").expect(301, done); }); it("Should handle multiple Route Parameters redirects properly", function (done) { @@ -596,10 +581,7 @@ describe("Redirect Routes Handler", function () { [{ pageType: "story-page", path: "/*" }], { redirectUrls: getRedirectUrl } ); - supertest(app) - .get("/india/foo/some-slug/slug") - .expect("Location", "/india/some-slug") - .expect(302, done); + supertest(app).get("/india/foo/some-slug/slug").expect("Location", "/india/some-slug").expect(302, done); }); it("Should handle interchanging route parameter redirects properly", function (done) { @@ -608,10 +590,7 @@ describe("Redirect Routes Handler", function () { [{ pageType: "story-page", path: "/*" }], { redirectUrls: getRedirectUrl } ); - supertest(app) - .get("/foo/something/bar") - .expect("Location", "/bar/something/foo") - .expect(301, done); + supertest(app).get("/foo/something/bar").expect("Location", "/bar/something/foo").expect(301, done); }); it("Should handle external redirects", function (done) { @@ -620,10 +599,7 @@ describe("Redirect Routes Handler", function () { [{ pageType: "story-page", path: "/*" }], { redirectUrls: getRedirectUrl } ); - supertest(app) - .get("/something/new") - .expect("Location", "https://www.google.com/something") - .expect(301, done); + supertest(app).get("/something/new").expect("Location", "https://www.google.com/something").expect(301, done); }); it("Should handle external redirects with params", function (done) { @@ -632,10 +608,7 @@ describe("Redirect Routes Handler", function () { [{ pageType: "story-page", path: "/*" }], { redirectUrls: getRedirectUrl } ); - supertest(app) - .get("/something/new1") - .expect("Location", "https://www.google.com/new1") - .expect(301, done); + supertest(app).get("/something/new1").expect("Location", "https://www.google.com/new1").expect(301, done); }); it("Should not crash if redirectUrls is not present", function (done) { @@ -646,10 +619,7 @@ describe("Redirect Routes Handler", function () { supertest(app) .get("/moved-temporarily-1") .expect("Location", "/temporarily-location-1") - .expect( - "Cache-Control", - "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400" - ) + .expect("Cache-Control", "public,max-age=15,s-maxage=120,stale-while-revalidate=120,stale-if-error=120") .expect("Vary", /Accept\-Encoding/) .expect("Surrogate-Key", "sp/42/102") .expect("Cache-Tag", "sp/42/102") From dc953b9c9f6b564d97c5d0ce226a1e0c9578e5eb Mon Sep 17 00:00:00 2001 From: VeenaYemmiganur Date: Thu, 30 Oct 2025 15:25:30 +0530 Subject: [PATCH 08/11] chore(release): 7.34.7-handle-500-issue.2 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index c69e6107..d7b23b78 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@quintype/framework", - "version": "7.34.7-handle-500-issue.1", + "version": "7.34.7-handle-500-issue.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@quintype/framework", - "version": "7.34.7-handle-500-issue.1", + "version": "7.34.7-handle-500-issue.2", "license": "ISC", "dependencies": { "@ampproject/toolbox-optimizer": "2.8.3", diff --git a/package.json b/package.json index 33112020..6c9c0836 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@quintype/framework", - "version": "7.34.7-handle-500-issue.1", + "version": "7.34.7-handle-500-issue.2", "description": "Libraries to help build Quintype Node.js apps", "main": "index.js", "engines": { From b9f3f2612d6cd031387243f2420d1090a10eb317 Mon Sep 17 00:00:00 2001 From: VeenaYemmiganur Date: Fri, 31 Oct 2025 19:35:57 +0530 Subject: [PATCH 09/11] revert. dummy commit - with cache header timers --- server/handlers/cdn-caching.js | 2 +- test/integration/custom-route-handler-test.js | 14 +++++++------- test/integration/isomorphic-handler-test.js | 15 +++++++++------ test/integration/url-redirect-test.js | 2 +- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/server/handlers/cdn-caching.js b/server/handlers/cdn-caching.js index 027978d2..34c94db9 100644 --- a/server/handlers/cdn-caching.js +++ b/server/handlers/cdn-caching.js @@ -42,7 +42,7 @@ exports.addCacheHeadersToResult = function addCacheHeadersToResult({ } else { res.setHeader( "Cache-Control", - `public,max-age=${maxAge},s-maxage=120,stale-while-revalidate=120,stale-if-error=120` + `public,max-age=${maxAge},s-maxage=${sMaxAge},stale-while-revalidate=1000,stale-if-error=${STALE_IF_ERROR_CACHE_DURATION}` ); } diff --git a/test/integration/custom-route-handler-test.js b/test/integration/custom-route-handler-test.js index bffeaf52..28abb82a 100644 --- a/test/integration/custom-route-handler-test.js +++ b/test/integration/custom-route-handler-test.js @@ -121,7 +121,7 @@ describe("Custom Route Handler", function () { supertest(app) .get("/moved-permanently") .expect("Location", "/permanent-location") - .expect("Cache-Control", "public,max-age=15,s-maxage=120,stale-while-revalidate=120,stale-if-error=120") + .expect("Cache-Control", "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400") .expect("Vary", /Accept\-Encoding/) .expect("Surrogate-Key", "sp/42/101") .expect("Cache-Tag", "sp/42/101") @@ -136,7 +136,7 @@ describe("Custom Route Handler", function () { supertest(app) .get("/moved-temporarily") .expect("Location", "/temporary-location") - .expect("Cache-Control", "public,max-age=15,s-maxage=120,stale-while-revalidate=120,stale-if-error=120") + .expect("Cache-Control", "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400") .expect("Vary", /Accept\-Encoding/) .expect("Surrogate-Key", "sp/42/102") .expect("Cache-Tag", "sp/42/102") @@ -152,7 +152,7 @@ describe("Custom Route Handler", function () { supertest(app) .get("/static-with-header-footer") .expect("Content-Type", /html/) - .expect("Cache-Control", "public,max-age=15,s-maxage=120,stale-while-revalidate=120,stale-if-error=120") + .expect("Cache-Control", "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400") .expect("Vary", "Accept-Encoding") .expect("Surrogate-Key", "sp/42/103") .expect("Cache-Tag", "sp/42/103") @@ -174,7 +174,7 @@ describe("Custom Route Handler", function () { supertest(app) .get("/static-without-header-footer") .expect("Content-Type", /html/) - .expect("Cache-Control", "public,max-age=15,s-maxage=120,stale-while-revalidate=120,stale-if-error=120") + .expect("Cache-Control", "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400") .expect("Vary", "Accept-Encoding") .expect("Surrogate-Key", "sp/42/104") .expect("Cache-Tag", "sp/42/104") @@ -236,7 +236,7 @@ describe("Custom Route Handler", function () { supertest(app) .get("/moved-absolute") .expect("Location", "https://www.google.com") - .expect("Cache-Control", "public,max-age=15,s-maxage=120,stale-while-revalidate=120,stale-if-error=120") + .expect("Cache-Control", "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400") .expect("Vary", /Accept\-Encoding/) .expect("Surrogate-Key", "sp/42/105") .expect("Cache-Tag", "sp/42/105") @@ -250,7 +250,7 @@ describe("Custom Route Handler", function () { ); supertest(app) .get("/static-with-mime-type") - .expect("Cache-Control", "public,max-age=15,s-maxage=120,stale-while-revalidate=120,stale-if-error=120") + .expect("Cache-Control", "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400") .expect("Vary", /Accept\-Encoding/) .expect("Surrogate-Key", "sp/42/105") .expect("Cache-Tag", "sp/42/105") @@ -265,7 +265,7 @@ describe("Custom Route Handler", function () { ); supertest(app) .get("/static-without-header-footer") - .expect("Cache-Control", "public,max-age=15,s-maxage=120,stale-while-revalidate=120,stale-if-error=120") + .expect("Cache-Control", "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400") .expect("Vary", "Accept-Encoding") .expect("Surrogate-Key", "sp/42/104") .expect("Cache-Tag", "sp/42/104") diff --git a/test/integration/isomorphic-handler-test.js b/test/integration/isomorphic-handler-test.js index a6536f14..f0950672 100644 --- a/test/integration/isomorphic-handler-test.js +++ b/test/integration/isomorphic-handler-test.js @@ -200,7 +200,7 @@ describe("Isomorphic Handler", function () { supertest(app) .get("/") .expect("Content-Type", /html/) - .expect("Cache-Control", "public,max-age=15,s-maxage=120,stale-while-revalidate=120,stale-if-error=120") + .expect("Cache-Control", "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400") .expect("Vary", "Accept-Encoding") .expect("Surrogate-Key", "foo bar") .expect("Cache-Tag", "foo,bar") @@ -503,7 +503,7 @@ describe("Isomorphic Handler", function () { .then((res) => { const cacheControl = res.header["cache-control"]; const cacheTag = res.header["cache-tag"]; - assert.equal(cacheControl, "public,max-age=15,s-maxage=120,stale-while-revalidate=120,stale-if-error=120"); + assert.equal(cacheControl, "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400"); assert.equal(cacheTag, "c/1/abcdefgh"); }) .then(done); @@ -631,7 +631,7 @@ describe("Isomorphic Handler", function () { const cacheControl = res.header["cache-control"]; const edgeCacheTag = res.header["edge-cache-tag"]; const contentSecurityPolicy = res.header["content-security-policy"]; - assert.equal(cacheControl, "public,max-age=15,s-maxage=120,stale-while-revalidate=120,stale-if-error=120"); + assert.equal(cacheControl, "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400"); assert.equal(edgeCacheTag, "c/1/abcdefgh"); assert.equal( contentSecurityPolicy, @@ -670,7 +670,7 @@ describe("Isomorphic Handler", function () { const cacheControl = res.header["cache-control"]; const edgeCacheTag = res.header["edge-cache-tag"]; const contentSecurityPolicy = res.header["content-security-policy"]; - assert.equal(cacheControl, "public,max-age=15,s-maxage=120,stale-while-revalidate=120,stale-if-error=120"); + assert.equal(cacheControl, "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400"); assert.equal(edgeCacheTag, "c/1/abcdefgh"); assert.equal( contentSecurityPolicy, @@ -706,7 +706,10 @@ describe("Isomorphic Handler", function () { .expect(200) .then((res) => { const cacheControl = res.header["cache-control"]; - assert.equal(cacheControl, "public,max-age=15,s-maxage=120,stale-while-revalidate=120,stale-if-error=120"); + assert.equal( + cacheControl, + "public,max-age=15,s-maxage=1800,stale-while-revalidate=1000,stale-if-error=14400" + ); }) .then(done); }); @@ -727,7 +730,7 @@ describe("Isomorphic Handler", function () { .expect(200) .then((res) => { const cacheControl = res.header["cache-control"]; - assert.equal(cacheControl, "public,max-age=15,s-maxage=120,stale-while-revalidate=120,stale-if-error=120"); + assert.equal(cacheControl, "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400"); }) .then(done); }); diff --git a/test/integration/url-redirect-test.js b/test/integration/url-redirect-test.js index 1ee791f4..be8e9763 100644 --- a/test/integration/url-redirect-test.js +++ b/test/integration/url-redirect-test.js @@ -619,7 +619,7 @@ describe("Redirect Routes Handler", function () { supertest(app) .get("/moved-temporarily-1") .expect("Location", "/temporarily-location-1") - .expect("Cache-Control", "public,max-age=15,s-maxage=120,stale-while-revalidate=120,stale-if-error=120") + .expect("Cache-Control", "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400") .expect("Vary", /Accept\-Encoding/) .expect("Surrogate-Key", "sp/42/102") .expect("Cache-Tag", "sp/42/102") From 4372e4e9a3b5a1b2729fbe569b3fe3a4c8c766f2 Mon Sep 17 00:00:00 2001 From: VeenaYemmiganur Date: Fri, 31 Oct 2025 19:36:54 +0530 Subject: [PATCH 10/11] revert. dummy commit - with cache header timers --- server/handlers/isomorphic-handler.js | 1 - 1 file changed, 1 deletion(-) diff --git a/server/handlers/isomorphic-handler.js b/server/handlers/isomorphic-handler.js index 6b6ae0fa..e925b43c 100644 --- a/server/handlers/isomorphic-handler.js +++ b/server/handlers/isomorphic-handler.js @@ -486,7 +486,6 @@ exports.handleIsomorphicRoute = function handleIsomorphicRoute( return res.redirect(301, result.data.location); } - // For server errors (>=500),send statuss if (statusCode >= 500) { return res.sendStatus(statusCode); } From 57e6a6a94f33113579abb1035b4e590f16cc2cb1 Mon Sep 17 00:00:00 2001 From: VeenaYemmiganur Date: Fri, 31 Oct 2025 19:42:24 +0530 Subject: [PATCH 11/11] chore(release): 7.34.7-handle-500-issue.3 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index d7b23b78..e61f4443 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@quintype/framework", - "version": "7.34.7-handle-500-issue.2", + "version": "7.34.7-handle-500-issue.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@quintype/framework", - "version": "7.34.7-handle-500-issue.2", + "version": "7.34.7-handle-500-issue.3", "license": "ISC", "dependencies": { "@ampproject/toolbox-optimizer": "2.8.3", diff --git a/package.json b/package.json index 6c9c0836..9a95b1d3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@quintype/framework", - "version": "7.34.7-handle-500-issue.2", + "version": "7.34.7-handle-500-issue.3", "description": "Libraries to help build Quintype Node.js apps", "main": "index.js", "engines": {