diff --git a/docs/Reference/Errors.md b/docs/Reference/Errors.md
index 93c2334425b..65cc3121908 100644
--- a/docs/Reference/Errors.md
+++ b/docs/Reference/Errors.md
@@ -30,7 +30,7 @@
- [FST_ERR_CTP_INVALID_CONTENT_LENGTH](#fst_err_ctp_invalid_content_length)
- [FST_ERR_CTP_EMPTY_JSON_BODY](#fst_err_ctp_empty_json_body)
- [FST_ERR_CTP_INSTANCE_ALREADY_STARTED](#fst_err_ctp_instance_already_started)
- - [FST_ERR_INSTANCE_ALREADY_LISTENING](#fst_err_instance_already_listening)
+ - [FST_ERR_INSTANCE_ALREADY_STARTED](#fst_err_instance_already_started)
- [FST_ERR_DEC_ALREADY_PRESENT](#fst_err_dec_already_present)
- [FST_ERR_DEC_DEPENDENCY_INVALID_TYPE](#fst_err_dec_dependency_invalid_type)
- [FST_ERR_DEC_MISSING_DEPENDENCY](#fst_err_dec_missing_dependency)
@@ -300,7 +300,7 @@ Below is a table with all the error codes used by Fastify.
| FST_ERR_CTP_INVALID_CONTENT_LENGTH | Request body size did not match Content-Length. | Check the request body size and the Content-Length header. | [#1168](https://github.com/fastify/fastify/pull/1168) |
| FST_ERR_CTP_EMPTY_JSON_BODY | Body cannot be empty when content-type is set to application/json. | Check the request body. | [#1253](https://github.com/fastify/fastify/pull/1253) |
| FST_ERR_CTP_INSTANCE_ALREADY_STARTED | Fastify is already started. | - | [#4554](https://github.com/fastify/fastify/pull/4554) |
-| FST_ERR_INSTANCE_ALREADY_LISTENING | Fastify instance is already listening. | - | [#4554](https://github.com/fastify/fastify/pull/4554) |
+| FST_ERR_INSTANCE_ALREADY_STARTED | Fastify instance is already started. | - | [#6098](https://github.com/fastify/fastify/pull/6098) |
| FST_ERR_DEC_ALREADY_PRESENT | A decorator with the same name is already registered. | Use a different decorator name. | [#1168](https://github.com/fastify/fastify/pull/1168) |
| FST_ERR_DEC_DEPENDENCY_INVALID_TYPE | The dependencies of decorator must be of type `Array`. | Use an array for the dependencies. | [#3090](https://github.com/fastify/fastify/pull/3090) |
| FST_ERR_DEC_MISSING_DEPENDENCY | The decorator cannot be registered due to a missing dependency. | Register the missing dependency. | [#1168](https://github.com/fastify/fastify/pull/1168) |
@@ -355,7 +355,7 @@ Below is a table with all the error codes used by Fastify.
| FST_ERR_ROUTE_BODY_LIMIT_OPTION_NOT_INT | `bodyLimit` option must be an integer. | Use an integer for the `bodyLimit` option. | [#4554](https://github.com/fastify/fastify/pull/4554) |
| FST_ERR_ROUTE_REWRITE_NOT_STR | `rewriteUrl` needs to be of type `string`. | Use a string for the `rewriteUrl`. | [#4554](https://github.com/fastify/fastify/pull/4554) |
| FST_ERR_REOPENED_CLOSE_SERVER | Fastify has already been closed and cannot be reopened. | - | [#2415](https://github.com/fastify/fastify/pull/2415) |
-| FST_ERR_REOPENED_SERVER | Fastify is already listening. | - | [#2415](https://github.com/fastify/fastify/pull/2415) |
+| FST_ERR_REOPENED_SERVER | Fastify is already started. | - | [#2415](https://github.com/fastify/fastify/pull/2415) |
| FST_ERR_PLUGIN_VERSION_MISMATCH | Installed Fastify plugin mismatched expected version. | Use a compatible version of the plugin. | [#2549](https://github.com/fastify/fastify/pull/2549) |
| FST_ERR_PLUGIN_CALLBACK_NOT_FN | Callback for a hook is not a function. | Use a function for the callback. | [#3106](https://github.com/fastify/fastify/pull/3106) |
| FST_ERR_PLUGIN_NOT_VALID | Plugin must be a function or a promise. | Use a function or a promise for the plugin. | [#3106](https://github.com/fastify/fastify/pull/3106) |
diff --git a/fastify.js b/fastify.js
index 1238cfdcde2..412e7fa6f79 100644
--- a/fastify.js
+++ b/fastify.js
@@ -67,7 +67,7 @@ const {
FST_ERR_SCHEMA_CONTROLLER_BUCKET_OPT_NOT_FN,
FST_ERR_AJV_CUSTOM_OPTIONS_OPT_NOT_OBJ,
FST_ERR_AJV_CUSTOM_OPTIONS_OPT_NOT_ARR,
- FST_ERR_INSTANCE_ALREADY_LISTENING,
+ FST_ERR_INSTANCE_ALREADY_STARTED,
FST_ERR_REOPENED_CLOSE_SERVER,
FST_ERR_ROUTE_REWRITE_NOT_STR,
FST_ERR_SCHEMA_ERROR_FORMATTER_NOT_FN,
@@ -536,7 +536,7 @@ function fastify (options) {
return fastify
function throwIfAlreadyStarted (msg) {
- if (fastify[kState].started) throw new FST_ERR_INSTANCE_ALREADY_LISTENING(msg)
+ if (fastify[kState].started) throw new FST_ERR_INSTANCE_ALREADY_STARTED(msg)
}
// HTTP injection handling
diff --git a/lib/errors.js b/lib/errors.js
index fe6b524565f..77f27bbfcc8 100644
--- a/lib/errors.js
+++ b/lib/errors.js
@@ -424,10 +424,10 @@ const codes = {
),
FST_ERR_REOPENED_SERVER: createError(
'FST_ERR_REOPENED_SERVER',
- 'Fastify is already listening'
+ 'Fastify is already started'
),
- FST_ERR_INSTANCE_ALREADY_LISTENING: createError(
- 'FST_ERR_INSTANCE_ALREADY_LISTENING',
+ FST_ERR_INSTANCE_ALREADY_STARTED: createError(
+ 'FST_ERR_INSTANCE_ALREADY_STARTED',
'Fastify instance is already listening. %s'
),
diff --git a/test/internals/errors.test.js b/test/internals/errors.test.js
index 2fa3562539a..a7aeaedce64 100644
--- a/test/internals/errors.test.js
+++ b/test/internals/errors.test.js
@@ -755,16 +755,16 @@ test('FST_ERR_REOPENED_SERVER', t => {
const error = new errors.FST_ERR_REOPENED_SERVER()
t.assert.strictEqual(error.name, 'FastifyError')
t.assert.strictEqual(error.code, 'FST_ERR_REOPENED_SERVER')
- t.assert.strictEqual(error.message, 'Fastify is already listening')
+ t.assert.strictEqual(error.message, 'Fastify is already started')
t.assert.strictEqual(error.statusCode, 500)
t.assert.ok(error instanceof Error)
})
-test('FST_ERR_INSTANCE_ALREADY_LISTENING', t => {
+test('FST_ERR_INSTANCE_ALREADY_STARTED', t => {
t.plan(5)
- const error = new errors.FST_ERR_INSTANCE_ALREADY_LISTENING()
+ const error = new errors.FST_ERR_INSTANCE_ALREADY_STARTED()
t.assert.strictEqual(error.name, 'FastifyError')
- t.assert.strictEqual(error.code, 'FST_ERR_INSTANCE_ALREADY_LISTENING')
+ t.assert.strictEqual(error.code, 'FST_ERR_INSTANCE_ALREADY_STARTED')
t.assert.strictEqual(error.message, 'Fastify instance is already listening. %s')
t.assert.strictEqual(error.statusCode, 500)
t.assert.ok(error instanceof Error)
diff --git a/test/internals/reply.test.js b/test/internals/reply.test.js
index c849869f867..e6dfde2f3eb 100644
--- a/test/internals/reply.test.js
+++ b/test/internals/reply.test.js
@@ -1794,7 +1794,7 @@ test('cannot set the replySerializer when the server is running', (t, done) => {
fastify.setReplySerializer(() => { })
t.assert.fail('this serializer should not be setup')
} catch (e) {
- t.assert.strictEqual(e.code, 'FST_ERR_INSTANCE_ALREADY_LISTENING')
+ t.assert.strictEqual(e.code, 'FST_ERR_INSTANCE_ALREADY_STARTED')
} finally {
done()
}
diff --git a/test/route.1.test.js b/test/route.1.test.js
index 6c568e3e5c1..55e21231eab 100644
--- a/test/route.1.test.js
+++ b/test/route.1.test.js
@@ -4,7 +4,7 @@ const { test } = require('node:test')
const sget = require('simple-get').concat
const Fastify = require('..')
const {
- FST_ERR_INSTANCE_ALREADY_LISTENING,
+ FST_ERR_INSTANCE_ALREADY_STARTED,
FST_ERR_ROUTE_METHOD_INVALID
} = require('../lib/errors')
const { getServerUrl } = require('./helper')
@@ -284,7 +284,7 @@ test('route', async t => {
handler: function (req, reply) {
reply.send({ hello: 'world' })
}
- }), new FST_ERR_INSTANCE_ALREADY_LISTENING('Cannot add route!'))
+ }), new FST_ERR_INSTANCE_ALREADY_STARTED('Cannot add route!'))
done()
})
diff --git a/test/types/errors.test-d.ts b/test/types/errors.test-d.ts
index 497759b0dfc..282381a34e7 100644
--- a/test/types/errors.test-d.ts
+++ b/test/types/errors.test-d.ts
@@ -68,7 +68,7 @@ expectAssignable(errorCodes.FST_ERR_ROUTE_BODY_LIMIT_OP
expectAssignable(errorCodes.FST_ERR_ROUTE_REWRITE_NOT_STR)
expectAssignable(errorCodes.FST_ERR_REOPENED_CLOSE_SERVER)
expectAssignable(errorCodes.FST_ERR_REOPENED_SERVER)
-expectAssignable(errorCodes.FST_ERR_INSTANCE_ALREADY_LISTENING)
+expectAssignable(errorCodes.FST_ERR_INSTANCE_ALREADY_STARTED)
expectAssignable(errorCodes.FST_ERR_PLUGIN_VERSION_MISMATCH)
expectAssignable(errorCodes.FST_ERR_PLUGIN_NOT_PRESENT_IN_INSTANCE)
expectAssignable(errorCodes.FST_ERR_PLUGIN_CALLBACK_NOT_FN)
diff --git a/types/errors.d.ts b/types/errors.d.ts
index d59bf6301c3..37888414668 100644
--- a/types/errors.d.ts
+++ b/types/errors.d.ts
@@ -69,7 +69,7 @@ export type FastifyErrorCodes = Record<
'FST_ERR_ROUTE_REWRITE_NOT_STR' |
'FST_ERR_REOPENED_CLOSE_SERVER' |
'FST_ERR_REOPENED_SERVER' |
- 'FST_ERR_INSTANCE_ALREADY_LISTENING' |
+ 'FST_ERR_INSTANCE_ALREADY_STARTED' |
'FST_ERR_PLUGIN_VERSION_MISMATCH' |
'FST_ERR_PLUGIN_NOT_PRESENT_IN_INSTANCE' |
'FST_ERR_PLUGIN_CALLBACK_NOT_FN' |