From c02551ecdf82236343dabc18478324b5d2ee0708 Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Tue, 27 May 2025 06:47:49 -0700 Subject: [PATCH 1/5] added a tiny timeout to let it shutdown properly Signed-off-by: Matteo Collina --- lib/plugin.js | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/plugin.js b/lib/plugin.js index 58cbdcc..a74cf5b 100644 --- a/lib/plugin.js +++ b/lib/plugin.js @@ -1,5 +1,6 @@ import { readFile } from 'node:fs/promises' import { basename } from 'node:path' +import { setTimeout as sleep } from 'node:timers/promises' const HTTP_METHODS = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS', 'TRACE'] @@ -28,6 +29,10 @@ export async function plugin (server, opts) { done(null, body) }) + server.addHook('onClose', async () => { + await sleep(100) + }) + for (const method of HTTP_METHODS) { server.route({ method, diff --git a/package.json b/package.json index 3bc9b9d..ea616c1 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "homepage": "https://github.com/platformatic/php#readme", "dependencies": { "@fastify/static": "^8.2.0", - "@platformatic/php-node": "1.0.1", + "@platformatic/php-node": "1.0.2", "@platformatic/service": "^2.63.3", "json-schema-to-typescript": "^15.0.4" }, From 3bfe5fb1ff6006d13c961617e42d92fd7e9380ff Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Tue, 27 May 2025 06:54:18 -0700 Subject: [PATCH 2/5] Increasing the timeout Signed-off-by: Matteo Collina --- lib/plugin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/plugin.js b/lib/plugin.js index a74cf5b..f9e231d 100644 --- a/lib/plugin.js +++ b/lib/plugin.js @@ -30,7 +30,7 @@ export async function plugin (server, opts) { }) server.addHook('onClose', async () => { - await sleep(100) + await sleep(1000) }) for (const method of HTTP_METHODS) { From 4d04583ad3e27d639cab79ddc1a723d659d97a3f Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Tue, 27 May 2025 06:59:53 -0700 Subject: [PATCH 3/5] move the wait outside Signed-off-by: Matteo Collina --- lib/plugin.js | 5 ----- test/plugin.test.js | 5 ++++- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/plugin.js b/lib/plugin.js index f9e231d..58cbdcc 100644 --- a/lib/plugin.js +++ b/lib/plugin.js @@ -1,6 +1,5 @@ import { readFile } from 'node:fs/promises' import { basename } from 'node:path' -import { setTimeout as sleep } from 'node:timers/promises' const HTTP_METHODS = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS', 'TRACE'] @@ -29,10 +28,6 @@ export async function plugin (server, opts) { done(null, body) }) - server.addHook('onClose', async () => { - await sleep(1000) - }) - for (const method of HTTP_METHODS) { server.route({ method, diff --git a/test/plugin.test.js b/test/plugin.test.js index c7d4607..55623c9 100644 --- a/test/plugin.test.js +++ b/test/plugin.test.js @@ -5,6 +5,7 @@ import { resolve, join } from 'node:path' import { test } from 'node:test' import { stackable } from '../lib/index.js' import formAutoContet from 'form-auto-content' +import { setTimeout as sleep } from 'node:timers/promises' async function startStackable (t, docroot = join(import.meta.dirname, './fixtures/hello'), opts = {}) { const config = { @@ -21,9 +22,11 @@ async function startStackable (t, docroot = join(import.meta.dirname, './fixture } } - const server = await buildServer(config, stackable) + let server = await buildServer(config, stackable) t.after(async () => { await server.close() + server = null + await sleep(1000) // wait for the server to close }) return server From 6a1ecc14e9250ecd063bc601c593ca575cd72585 Mon Sep 17 00:00:00 2001 From: Stephen Belanger Date: Wed, 28 May 2025 17:54:36 +0800 Subject: [PATCH 4/5] Bump to v1.0.3 --- package.json | 2 +- test/plugin.test.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index ea616c1..0704d7e 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "homepage": "https://github.com/platformatic/php#readme", "dependencies": { "@fastify/static": "^8.2.0", - "@platformatic/php-node": "1.0.2", + "@platformatic/php-node": "^1.0.3", "@platformatic/service": "^2.63.3", "json-schema-to-typescript": "^15.0.4" }, diff --git a/test/plugin.test.js b/test/plugin.test.js index 55623c9..3bebeb4 100644 --- a/test/plugin.test.js +++ b/test/plugin.test.js @@ -12,7 +12,7 @@ async function startStackable (t, docroot = join(import.meta.dirname, './fixture $schema: '../../schema.json', module: '../../lib/index.js', php: { - docroot + docroot }, port: 0, server: { @@ -43,7 +43,7 @@ test('PHP hello world', async t => { test('post data', async t => { const server = await startStackable(t) const res = await server.inject({ - url: '/post.php', + url: '/post.php', method: 'POST', ...formAutoContet({ 'foo': 'bar' From 7b19f336b5a9e66d8841154876ec3bb27ae0329b Mon Sep 17 00:00:00 2001 From: Stephen Belanger Date: Wed, 28 May 2025 19:28:29 +0800 Subject: [PATCH 5/5] Bump to v1.0.4 --- .gitignore | 4 ++++ package.json | 2 +- test/plugin.test.js | 5 +---- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 2d4b931..8ed26fb 100644 --- a/.gitignore +++ b/.gitignore @@ -136,3 +136,7 @@ dist .pnp.* plt-php wordpress + +package-lock.json +pnpm-lock.yaml +yarn.lock diff --git a/package.json b/package.json index 0704d7e..44eb5cb 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "homepage": "https://github.com/platformatic/php#readme", "dependencies": { "@fastify/static": "^8.2.0", - "@platformatic/php-node": "^1.0.3", + "@platformatic/php-node": "^1.0.4", "@platformatic/service": "^2.63.3", "json-schema-to-typescript": "^15.0.4" }, diff --git a/test/plugin.test.js b/test/plugin.test.js index 3bebeb4..e2a9af1 100644 --- a/test/plugin.test.js +++ b/test/plugin.test.js @@ -5,7 +5,6 @@ import { resolve, join } from 'node:path' import { test } from 'node:test' import { stackable } from '../lib/index.js' import formAutoContet from 'form-auto-content' -import { setTimeout as sleep } from 'node:timers/promises' async function startStackable (t, docroot = join(import.meta.dirname, './fixtures/hello'), opts = {}) { const config = { @@ -22,11 +21,9 @@ async function startStackable (t, docroot = join(import.meta.dirname, './fixture } } - let server = await buildServer(config, stackable) + const server = await buildServer(config, stackable) t.after(async () => { await server.close() - server = null - await sleep(1000) // wait for the server to close }) return server