Skip to content

Commit

Permalink
Merge branch 'main' into issue-4136
Browse files Browse the repository at this point in the history
  • Loading branch information
siddhsuresh committed May 1, 2023
2 parents 9cd28bb + fa30de4 commit 0685b8c
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 11 deletions.
10 changes: 10 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -3907,6 +3907,16 @@
"code",
"test"
]
},
{
"login": "gjmoed",
"name": "G.J. Moed",
"avatar_url": "https://avatars.githubusercontent.com/u/4458993?v=4",
"profile": "https://github.com/gjmoed",
"contributions": [
"doc",
"code"
]
}
],
"contributorsPerLine": 7,
Expand Down
5 changes: 5 additions & 0 deletions .changeset/fresh-crews-chew.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@blitzjs/next": minor
---

Fix the DYNAMIC_SERVER_USAGE error for Next.js 13.3.1+
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<img alt="" src="https://img.shields.io/badge/Join%20our%20community-6700EB.svg?style=for-the-badge&labelColor=000000&logoWidth=20&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAQ9SURBVHgB7d3dVdtAEIbhcSpICUoH0IEogQqSVBBSAU4FSSpIOoAORAfQgSghHXzZ1U/YcMD4R9rZmf2ec3y448LyiNf27iLiGIAmPLrweC9Un3DhrzG6EarLNP09nlwJ1SOZ/lQr5N80/S/p2QMVCBf5N17XCfm1Y/rBHqjAG9PPHvBsz+mf9WAP+HLA9M/YA14cOP2payH7jpj+VCtk1wnTP+vj7xCy6cTpn7EHLMLp059iD1iD8eveJbVCNsSLheX1YA/YgOWnf8YeKB3Wmf7Ud6Fy4f/FHmtpxbl3YlC4MJ/Cj0bWdwPnPbARg+L0S54XQHS32WwuxClzd4CM0z9rPf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BWqB7PeqDn9FcIT//kcitUn6kHOu/T/xfWzlQy3dEHhwAAAABJRU5ErkJggg==">
</a>
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
<a aria-label="All Contributors" href="#contributors-"><img alt="" src="https://img.shields.io/badge/all_contributors-412-17BB8A.svg?style=for-the-badge&labelColor=000000"></a>
<a aria-label="All Contributors" href="#contributors-"><img alt="" src="https://img.shields.io/badge/all_contributors-413-17BB8A.svg?style=for-the-badge&labelColor=000000"></a>
<!-- ALL-CONTRIBUTORS-BADGE:END -->
<a aria-label="License" href="https://github.com/blitz-js/blitz/blob/main/LICENSE">
<img alt="" src="https://img.shields.io/npm/l/blitz.svg?style=for-the-badge&labelColor=000000&color=blue">
Expand Down Expand Up @@ -725,6 +725,7 @@ Thanks to these wonderful people ([emoji key](https://allcontributors.org/docs/e
<td align="center"><a href="https://github.com/vitaliemiron"><img src="https://avatars.githubusercontent.com/u/45145592?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Vitalie</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=vitaliemiron" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=vitaliemiron" title="Code">💻</a></td>
<td align="center"><a href="https://estevao.org"><img src="https://avatars.githubusercontent.com/u/19409687?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Nelson Estevão</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=nelsonmestevao" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=nelsonmestevao" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/dbrxnds"><img src="https://avatars.githubusercontent.com/u/32268383?v=4?s=100" width="100px;" alt=""/><br /><sub><b>David</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=dbrxnds" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=dbrxnds" title="Code">💻</a> <a href="https://github.com/blitz-js/blitz/commits?author=dbrxnds" title="Tests">⚠️</a></td>
<td align="center"><a href="https://github.com/gjmoed"><img src="https://avatars.githubusercontent.com/u/4458993?v=4?s=100" width="100px;" alt=""/><br /><sub><b>G.J. Moed</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=gjmoed" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=gjmoed" title="Code">💻</a></td>
</tr>
</table>

Expand Down
14 changes: 12 additions & 2 deletions packages/blitz/src/cli/utils/codegen-tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const codegenTasks = async () => {
*/
const nextDir = await resolveCwd("next")
const nextClientIndex = join(nextDir, "../..", "client", "index.js")
console.log(nextClientIndex)
const readFile = await fs.readFile(nextClientIndex)
const packageJson = await getPackageJson()
const version = packageJson.dependencies.next
Expand All @@ -39,15 +40,24 @@ export const codegenTasks = async () => {
)
await fs.writeFile(nextClientIndex, updatedFile)
log.success("Next.js was successfully patched with a React Suspense fix")
} else if (nextVersion && semver.satisfies(nextVersion, ">=13.2")) {
} else if (nextVersion && semver.satisfies(nextVersion, "13.1 - 13.3.0")) {
const updatedFile = readFile
.toString()
.replace(
/_onRecoverableError\.default/,
/_onRecoverableError\.default$/gm,
`(err) => (err.toString().includes("DYNAMIC_SERVER_USAGE") || err.toString().includes("could not finish this Suspense boundary") || err.toString().includes("Minified React error #419")) ? null : _onRecoverableError.default(err)`,
)
await fs.writeFile(nextClientIndex, updatedFile)
log.success("Next.js was successfully patched with a React Suspense fix")
} else if (nextVersion && semver.satisfies(nextVersion, ">=13.3.1")) {
const updatedFile = readFile
.toString()
.replace(
/_onrecoverableerror\.default$/gm,
`(err) => (err.toString().includes("DYNAMIC_SERVER_USAGE") || err.toString().includes("could not finish this Suspense boundary") || err.toString().includes("Minified React error #419")) ? null : _onrecoverableerror.default(err)`,
)
await fs.writeFile(nextClientIndex, updatedFile)
log.success("Next.js was successfully patched with a React Suspense fix")
}
} catch (err) {
log.error(JSON.stringify(err, null, 2))
Expand Down
16 changes: 8 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0685b8c

Please sign in to comment.