#When batching — Error: Ensure bailed, found path does not match ensure type

6 messages · Page 1 of 1 (latest)

carmine pivot
#

I have decided to implement batching into several functions, however one of the requests in each batch will fail with a 500 status code and log this:

Error: Ensure bailed, found path does not match ensure type (pages/app)
at ensurePageImpl (.../node_modules/next/dist/server/dev/on-demand-entry-handler.js:483:23) {
  digest: undefined
}

Here's a function that triggers it, even though batching in general is causing issues:

const checkKeywords = async (content) => {
  setGeneratingContent(true);

  const promises = content.map((item) =>
    fetch("/api/check-keywords", {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify(item),
    })
      .then((res) => res.json())
      .catch((err) => ({ error: true, message: err.message }))
  );

  try {
    const results = await Promise.all(promises);
    const successfulResults = results.filter((result) => !result.error);

    // Processing retries for failed results
    for (let result of results.filter((r) => r.error)) {
      try {
        const retryResponse = await fetch("/api/check-keywords", {
          method: "POST",
          headers: { "Content-Type": "application/json" },
          body: JSON.stringify(result),
        });
        const retryData = await retryResponse.json();
        successfulResults.push(retryData);
      } catch (retryError) {
        console.error("Retry failed:", retryError);
      }
    }

    const combinedData = successfulResults.flat();

    setGeneratedContent(combinedData);
    setCurrentStep(2);
  } catch (err) {
    console.error("An error occurred while generating content:", err);
  } finally {
    setGeneratingContent(false);
  }
};

Any idea?

arctic pumiceBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

carmine pivot
#

bump

carmine pivot
#

Bump

carmine pivot
#

bump

carmine pivot
#

bump