Update error handling in publish scripts (#62754)
Seems we aren't ignoring the already published error correctly. x-ref: https://github.com/vercel/next.js/actions/runs/8118349923/job/22192598805 Closes NEXT-2668
This commit is contained in:
parent
be87132327
commit
04b13f52a5
2 changed files with 22 additions and 11 deletions
|
@ -24,6 +24,7 @@ const cwd = process.cwd()
|
|||
await Promise.all(
|
||||
platforms.map(async (platform) => {
|
||||
await publishSema.acquire()
|
||||
let output = ''
|
||||
|
||||
try {
|
||||
let binaryName = `next-swc.${platform}.node`
|
||||
|
@ -41,7 +42,7 @@ const cwd = process.cwd()
|
|||
path.join(nativePackagesDir, platform, 'package.json'),
|
||||
JSON.stringify(pkg, null, 2)
|
||||
)
|
||||
await execa(
|
||||
const child = execa(
|
||||
`npm`,
|
||||
[
|
||||
`publish`,
|
||||
|
@ -52,14 +53,20 @@ const cwd = process.cwd()
|
|||
],
|
||||
{ stdio: 'inherit' }
|
||||
)
|
||||
const handleData = (type) => (chunk) => {
|
||||
process[type].write(chunk)
|
||||
output += chunk.toString()
|
||||
}
|
||||
child.stdout?.on('data', handleData('stdout'))
|
||||
child.stderr?.on('data', handleData('stderr'))
|
||||
await child
|
||||
} catch (err) {
|
||||
// don't block publishing other versions on single platform error
|
||||
console.error(`Failed to publish`, platform, err)
|
||||
|
||||
if (
|
||||
err.message &&
|
||||
err.message.includes(
|
||||
'You cannot publish over the previously published versions'
|
||||
output.includes(
|
||||
'cannot publish over the previously published versions'
|
||||
)
|
||||
) {
|
||||
console.error('Ignoring already published error', platform, err)
|
||||
|
|
|
@ -42,9 +42,10 @@ const cwd = process.cwd()
|
|||
const publishSema = new Sema(2)
|
||||
|
||||
const publish = async (pkg, retry = 0) => {
|
||||
let output = ''
|
||||
try {
|
||||
await publishSema.acquire()
|
||||
await execa(
|
||||
const child = execa(
|
||||
`npm`,
|
||||
[
|
||||
'publish',
|
||||
|
@ -54,18 +55,21 @@ const cwd = process.cwd()
|
|||
'--ignore-scripts',
|
||||
...(isCanary ? ['--tag', 'canary'] : []),
|
||||
],
|
||||
{ stdio: 'inherit' }
|
||||
{ stdio: 'pipe' }
|
||||
)
|
||||
const handleData = (type) => (chunk) => {
|
||||
process[type].write(chunk)
|
||||
output += chunk.toString()
|
||||
}
|
||||
child.stdout?.on('data', handleData('stdout'))
|
||||
child.stderr?.on('data', handleData('stderr'))
|
||||
// Return here to avoid retry logic
|
||||
return
|
||||
return await child
|
||||
} catch (err) {
|
||||
console.error(`Failed to publish ${pkg}`, err)
|
||||
|
||||
if (
|
||||
err.message &&
|
||||
err.message.includes(
|
||||
'You cannot publish over the previously published versions'
|
||||
)
|
||||
output.includes('cannot publish over the previously published versions')
|
||||
) {
|
||||
console.error('Ignoring already published error', pkg)
|
||||
return
|
||||
|
|
Loading…
Reference in a new issue