From e61d19d366c247ea921373a55ec2a4081d80cc6c Mon Sep 17 00:00:00 2001 From: Arthur Fiorette Date: Wed, 3 Apr 2024 10:44:36 -0300 Subject: [PATCH] fix: avoid crashes when suspense cannot be loaded --- .changeset/curvy-ladybugs-boil.md | 5 +++++ packages/fastify-html-plugin/index.js | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 .changeset/curvy-ladybugs-boil.md diff --git a/.changeset/curvy-ladybugs-boil.md b/.changeset/curvy-ladybugs-boil.md new file mode 100644 index 00000000..17fb70f3 --- /dev/null +++ b/.changeset/curvy-ladybugs-boil.md @@ -0,0 +1,5 @@ +--- +'@kitajs/fastify-html-plugin': patch +--- + +Avoid crashes when suspense cannot be loaded diff --git a/packages/fastify-html-plugin/index.js b/packages/fastify-html-plugin/index.js index 35279052..08dc28b1 100644 --- a/packages/fastify-html-plugin/index.js +++ b/packages/fastify-html-plugin/index.js @@ -3,8 +3,10 @@ const fp = require('fastify-plugin'); const { isTagHtml } = require('./lib/is-tag-html'); -// loads SUSPENSE_ROOT -require('@kitajs/html/suspense'); +// Loads the suspense component if it wasn't already loaded +if (!globalThis.SUSPENSE_ROOT) { + require('@kitajs/html/suspense'); +} /** * @type {import('fastify').FastifyPluginCallback<