Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
d0dd1bc2
Unverified
Commit
d0dd1bc2
authored
Nov 12, 2018
by
Tim Neutkens
Committed by
GitHub
Nov 12, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Trim buildId returned from generateBuildId (#5634)
* Trim buildId returned from generateBuildId * Pass dir to function
parent
d8f87940
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
9 deletions
+30
-9
generatebuildid-not-a-string.md
errors/generatebuildid-not-a-string.md
+9
-0
index.js
packages/next/build/index.js
+21
-9
No files found.
errors/generatebuildid-not-a-string.md
0 → 100644
View file @
d0dd1bc2
# generateBuildId did not return a string
#### Why This Error Occurred
The most common cause for this issue is a custom
`next.config.js`
with the
`generateBuildId`
method defined, but it does not return a string.
#### Possible Ways to Fix It
Always return a string from generateBuildId.
packages/next/build/index.js
View file @
d0dd1bc2
...
...
@@ -10,22 +10,34 @@ import getBaseWebpackConfig from './webpack'
const
access
=
promisify
(
fs
.
access
)
const
writeFile
=
promisify
(
fs
.
writeFile
)
export
default
async
function
build
(
dir
,
conf
=
null
)
{
const
config
=
loadConfig
(
PHASE_PRODUCTION_BUILD
,
dir
,
conf
)
const
distDir
=
join
(
dir
,
config
.
distDir
)
async
function
generateBuildId
(
generate
,
fallback
)
{
let
buildId
=
await
generate
()
// If there's no buildId defined we'll fall back
if
(
buildId
===
null
)
{
buildId
=
fallback
()
}
let
buildId
=
await
config
.
generateBuildId
()
// defaults to a uuid
if
(
buildId
==
null
)
{
// nanoid is a small url-safe uuid generator
buildId
=
nanoid
()
if
(
typeof
buildId
!==
'string'
)
{
throw
new
Error
(
'generateBuildId did not return a string. https://err.sh/zeit/next.js/generatebuildid-not-a-string'
)
}
return
buildId
.
trim
()
}
async
function
ensureProjectDirectoryIsWriteAble
(
dir
)
{
try
{
await
access
(
dir
,
(
fs
.
constants
||
fs
).
W_OK
)
}
catch
(
err
)
{
console
.
error
(
`> Failed, build directory is not writeable. https://err.sh/zeit/next.js/build-dir-not-writeable`
)
throw
err
throw
new
Error
(
'Build directory is not writeable. https://err.sh/zeit/next.js/build-dir-not-writeable'
)
}
}
export
default
async
function
build
(
dir
,
conf
=
null
)
{
const
config
=
loadConfig
(
PHASE_PRODUCTION_BUILD
,
dir
,
conf
)
const
distDir
=
join
(
dir
,
config
.
distDir
)
const
buildId
=
await
generateBuildId
(
config
.
generateBuildId
,
nanoid
)
await
ensureProjectDirectoryIsWriteAble
(
dir
)
try
{
const
configs
=
await
Promise
.
all
([
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment