Skip to content

Commit 65f3005

Browse files
authored
chore(docs): Improve fs section of release notes (#29910)
1 parent 360cad7 commit 65f3005

File tree

1 file changed

+10
-1
lines changed
  • docs/docs/reference/release-notes/v3.0

1 file changed

+10
-1
lines changed

docs/docs/reference/release-notes/v3.0/index.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,16 @@ When those inputs change since the last build, the HTML files are marked to be r
6666

6767
### Avoid direct filesystem calls
6868

69-
As we mentioned, Gatsby tracks "inputs" used to generate HTML files. However, the `gatsby-ssr` file allows some arbitrary code execution. This includes for example `fs` reads. While Gatsby could also track files that are read, the custom code that does those reads might have some special logic that Gatsby is not aware of. If Gatsby discovers that those are used, it will disable "Incremental Builds"-mode to stay on the safe side (there will be warnings mentioning "unsafe builtin method").
69+
As we mentioned, Gatsby tracks "inputs" used to generate HTML files. However, the `gatsby-ssr` file allows some arbitrary code execution like using the [`fs` module](https://nodejs.org/api/fs.html). For example:
70+
71+
```js:title=gatsby-ssr.js
72+
const fs = require(`fs`)
73+
const someUntrackedInput = fs.readFileSync(`some-path.txt`)
74+
75+
// Rest of gatsby-ssr.js file
76+
```
77+
78+
While Gatsby could also track files that are read, the custom code that does those reads might have some special logic that Gatsby is not aware of. In the above example the filename could be generated and changed between builds, or the file read itself could change -- so we see this as "arbitrary" file reading. If Gatsby discovers that `fs` modules are used, it will disable "Incremental Builds"-mode to stay on the safe side (there will be warnings mentioning "unsafe builtin method").
7079

7180
If your `gatsby-ssr` (either site itself or plugin) make use of `fs` reads, head over to [migrating from v2 to v3 guide](/docs/reference/release-notes/migrating-from-v2-to-v3/#using-fs-in-SSR) and check how to migrate.
7281

0 commit comments

Comments
 (0)