sindresorhus / ora

Elegant terminal spinner
MIT License
9.08k stars 269 forks source link

ora@7 dependency causes seg fault (was seg fault on mac m1 arm) #229

Open ahgittin opened 1 year ago

ahgittin commented 1 year ago

I'm working on a large TS project which builds a CLI with spinners and when we tried upgrading our deps this month, the CLI started giving seg faults. We identified this as the dependency which caused it; reverting it to v6.3.1 and the problem went away.

I've no idea why; it doesn't look like much changed in this project to cause such a problem, so it could be something in one of the upstream strip ansi or string width libraries, or some other quirk of CLI builds which always seem a dark magic. But since presumably CLIs are a common environment for this library I thought I'd note this.

The key elements of our CLI build are tsc, esbuild, and pkg:

npx tsc
npx esbuild ./src/main.js --bundle --platform=node --outfile=target/esb/esb.js --external:shelljs
npx pkg target/esb/esb.js -t node16-macos-arm64 --output target/pkg/maeztro-macos-arm64

Apologies I've not had time to investigate why; if I do I'll add details.

kanadgupta commented 1 year ago

Hi there, our team is also running into this. We've been able to reproduce the segmentation fault with ora@7 on multiple operating systems/architectures, whether compiling using esbuild or rollup. I've also confirmed that the seg fault doesn't appear when downgrading to ora@6.

I haven't been able to figure out the root cause but my theory is that a recent change to the ora dependency tree isn't playing nicely with the way pkg builds binaries. I create a minimal example repository that demonstrates the issue and documents my findings: https://github.com/kanadgupta/ora-seg-fault-bug

@ahgittin mind renaming this issue so it's not specific to macOS? I've been keeping a running list of affected platforms here: https://github.com/kanadgupta/ora-seg-fault-bug#platform-info