Skip to content

Script failing after v8.6.2 -> v8.7.0 upgrade #1266

@Tobbe

Description

@Tobbe

This discussion started over at #1263 but I have now verified that upgrading to v8.7.0 makes my script fail, and then downgrading to v8.6.2 again makes it pass. So something definitely changed between those versions that changes the behavior in unexpected ways 🙂

Summary of #1263

zx changes: 8.6.2...8.7.0

I'm seeing this error in our CI after upgrading to v8.7.0.

Error: Command failed with exit code 1: node "D:\a\cedar\test-project\node_modules\prisma\build\index.js" generate --schema="D:\a\cedar\test-project\api\db\schema.prisma"
Error: 
EPERM: operation not permitted, unlink 'D:\a\cedar\test-project\node_modules\.prisma\client\query_engine-windows.dll.node'

The error I'm getting is discussed at great length here: prisma/prisma#9184

The test passes on Ubuntu. So only Windows is affected

Additional info and questions

Here's the PR where I'm trying to upgrade to v8.7.0 cedarjs/cedar#196

A trimmed down snippet of the code in my script that uses zx looks like this:

console.log('Action: Running `yarn rw serve api`')
await $`yarn rw build api`
const apiServer = $`yarn rw serve api`.nothrow()

// Wait for the api server to start
await new Promise((resolve) => {
  apiServer.stdout.on('data', (data) => {
    if (data.includes('API server listening at')) {
      resolve(null)
    }
  })
})

console.log('Action: Triggering the function')
// ... just calling fetch() here

const apiServerPid = apiServer.pid
console.log('apiServer pid', apiServerPid)

if (apiServerPid) {
  const ptree = await ps.tree({ pid: apiServerPid, recursive: true })
  console.log('ptree', JSON.stringify(ptree, null, 2))
}

console.log('Action: Stopping the api server')
await apiServer.kill('SIGINT')

if (apiServerPid) {
  const pinfo = await ps.lookup({ pid: apiServerPid })
  console.log('pinfo', JSON.stringify(pinfo, null, 2))
}

This is the output I get on a successful run on Ubuntu

Action: Running `yarn rw serve api`
Action: Triggering the function
apiServer pid 3724
ptree [
  {
    "pid": "3735",
    "ppid": "3724",
    "command": "/opt/hostedtoolcache/node/20.19.3/x64/bin/node",
    "arguments": [
      "/home/runner/work/cedar/test-project/node_modules/@cedarjs/core/dist/bins/redwood.js",
      "serve",
      "api"
    ]
  }
]
Action: Stopping the api server
pinfo [
  {
    "pid": "3724",
    "ppid": "3169",
    "command": "/opt/hostedtoolcache/node/20.19.3/x64/bin/node",
    "arguments": [
      "/usr/local/lib/node_modules/corepack/dist/yarn.js",
      "rw",
      "serve",
      "api"
    ]
  }
]

This is the output I get on Windows

Action: Running `yarn rw serve api`
Action: Triggering the function
apiServer pid 5492
ptree []
Action: Stopping the api server
pinfo []

Two questions:

  1. I was expecting pinfo to be empty after killing the process. Why isn't it?
  2. Why don't I get any process info on Windows?

One observation:

  1. If I remove .nothrow() the script fails on Ubuntu, but it fails much later. I don't understand why. Example here https://github.com/cedarjs/cedar/actions/runs/16236074368/job/45846404846

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions