Skip to content

chore: sync fork with upstream microsoft/node-pty - #90

Closed
bwp91 wants to merge 293 commits into
alpha-0.15.0from
sync/upstream-main
Closed

chore: sync fork with upstream microsoft/node-pty#90
bwp91 wants to merge 293 commits into
alpha-0.15.0from
sync/upstream-main

Conversation

@bwp91

@bwp91 bwp91 commented Jul 19, 2026

Copy link
Copy Markdown

What this is

A full sync of this fork with upstream microsoft/node-pty, done as a true git merge so GitHub reports the fork as 0 commits behind upstream. The fork point was October 2023 — this brings in ~284 upstream commits while keeping the fork's packaging and multiarch prebuild distribution intact.

⚠️ This PR must be merged with a merge commit ("Create a merge commit"), not squash or rebase. A squash/rebase would discard the upstream commit history and put the fork straight back to "284 commits behind".

What we gain from upstream

Bug fixes relevant to real users:

Features (all additive):

  • write() accepts Buffer as well as strings
  • resize() supports optional pixel dimensions
  • Optional useConptyDll mode with bundled conpty 1.25 (third_party/conpty)

Structural:

  • winpty is removed (Remove support for winpty microsoft/node-pty#868) — the deps/winpty tree (185 files) is gone. Windows uses conpty only, which requires Windows 10 1809+ (October 2018). Older builds are long EOL and Node 18+ barely runs there; noted as a footnote rather than a breaking change
  • Modern toolchain: TypeScript 5, ESLint 10 flat config, node-gyp 11, stricter native compile flags (/sdl, -fstack-protector-strong)

Merge policy used

Area Resolution
src/, typings/, binding.gyp, scripts/post-install.js, eslint config upstream, wholesale
deps/winpty, src/win/winpty.cc, .eslintrc.js, .npmrc, azure-pipelines.yml deleted (accepted upstream deletions)
README.md, package identity, release workflows, .prebuild/ ours
package.json hand-merged — see below

package.json: keeps the fork's name/version, prebuild-install install chain (check-prebuild → prebuild-install → node-gyp), bundled linux prebuilds in files, engines, overrides, and allowScripts; adopts upstream's devDependency toolchain; drops deps/ from files (winpty is gone); ships upstream's third_party/ conpty payload.

The one deliberate code divergence: upstream centralised native loading in loadNativeModule() (src/utils.ts), which only looks for plain names like pty.node. This fork's bundled linux prebuilds use prebuildify's abi-tagged names (e.g. node.abi127.node). loadNativeModule() gained a small, clearly-commented fork preamble that consults the existing prebuild-file-path helper first, then falls through to upstream's search order. src/prebuild-loader.ts became orphaned as a result and is removed in a follow-up commit.

Impact on homebridge-config-ui-x

None expected. The UI uses spawn() + onData/onExit/write/resize/kill, all unchanged. Linux prebuild coverage (incl. armv6/v7 and musl) is produced by this repo's own workflows, which are untouched. macOS continues to build from source for now (#92 — which becomes much easier after this merge, since upstream's loader already reads plain-named binaries from prebuilds/<platform>-<arch>/; bundling darwin/win32 prebuilds in the published package is the planned follow-up).

Testing done (macOS arm64)

  • Fresh npm install with regenerated lockfile — clean
  • tsc build and eslint (flat config) — clean
  • node-gyp rebuild from merged native source, then 24/24 mocha tests pass, including upstream's new ptmx/kqueue fd-leak regression tests
  • Live smoke test: spawned a pty through the built package, verified output + exit code
  • Note for local testing: npm install pulls the published v0.13.1 prebuild via prebuild-install, which masks merged native changes — rebuild with npx node-gyp rebuild before running tests

Other platforms need CI + the prebuild workflows to validate. Suggest releasing the next version as a beta and soaking it in a config-ui-x beta before stable.

🤖 Generated with Claude Code

Tyriar and others added 30 commits August 11, 2024 09:34
Copy right dll/exe based on npm_config_arch
Resolves warning:

src\win\path_util.cc(54): warning C6262: Function uses '131804' bytes of stack:  exceeds /analyze:stacksize '16384'.  Consider moving some data to heap.
Fixes warning:

deps\winpty\src\agent\Agent.cc(231): warning C4722: 'Agent::~Agent': destructor never returns, potential memory leak
…econstructor

Catch possible exceptions in ~Agent
Move to compile commands on postinstall for fixing intellisense
* chore: use node 20 and fix build

* chore: bump macOS deployment target

* spec: reduce flakyness

* Revert "chore: bump macOS deployment target"

This reverts commit d9d18b3.

---------

Co-authored-by: deepak1556 <hop2deep@gmail.com>
Also allows the CI pipeline to use the Unofficial template
fix: ensure proper cleanup of console process on shutdown
* Update to conpty v1.22

Fixes microsoft#490

* Add logs to show the problem happening

* spec: increase exit delay

* refactor: input and output handling with conpty

* Close the input read and output write handles after creating
  the client process
* Call ReleasePseudoConsole after creating the client process
  which will cause the output read handle to close when there
  is no more data from the session
* For manual termination via Kill, we close the input write handle
  and call into ClosePseudoConsole, we should then drain the output
  handle

NB: ideally draining the output handle should have been enough
to cause the client process to close but it doesn't work, we call
TerminateProcess to fix this case.

* chore: restore legacy conpty path

---------

Co-authored-by: deepak1556 <hop2deep@gmail.com>
* chore: add BinSkim flags to winpty

* Apply PR feedback
dependabot Bot and others added 15 commits May 7, 2026 11:00
Bumps [ip-address](https://github.com/beaugunderson/ip-address) from 10.0.1 to 10.2.0.
- [Commits](https://github.com/beaugunderson/ip-address/commits)

---
updated-dependencies:
- dependency-name: ip-address
  dependency-version: 10.2.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…crosoft#922)

The windows backend keeps a global vector of  `ptyHandles`.
Since the cleanup of the baton was moved into the per-pty watcher thread
(commit 17062cd):

- The watcher thread called `remove_pty_baton` without
  any lock, racing with other watchers and with JS-thread reads.
- `emplace_back` in `startProcess` could reallocate the vector while
  another thread was iterating it.
)

Bumps [brace-expansion](https://github.com/juliangruber/brace-expansion) from 5.0.5 to 5.0.6.
- [Release notes](https://github.com/juliangruber/brace-expansion/releases)
- [Commits](juliangruber/brace-expansion@v5.0.5...v5.0.6)

---
updated-dependencies:
- dependency-name: brace-expansion
  dependency-version: 5.0.6
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* Initial plan

* chore(examples/electron): update electron to 42.2.0

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
* Initial plan

* chore: bump eslint to 10.4.0

* chore: declare globals for eslint config

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
SetupExitCallback opens a kqueue() per spawned pty to wait on
NOTE_EXIT, but never closes it before the watcher thread returns,
leaking one kqueue fd per pty.spawn() for the host process lifetime.

The Chromium kill_mac.cc this is based on closes the kqueue via
ScopedFD; the equivalent here is an explicit close(kq) once the
kevent wait completes.
…icrosoft#930)

Bumps [undici](https://github.com/nodejs/undici) from 7.27.0 to 7.28.0.
- [Release notes](https://github.com/nodejs/undici/releases)
- [Commits](nodejs/undici@v7.27.0...v7.28.0)

---
updated-dependencies:
- dependency-name: undici
  dependency-version: 7.28.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [js-yaml](https://github.com/nodeca/js-yaml) from 4.1.1 to 4.2.0.
- [Changelog](https://github.com/nodeca/js-yaml/blob/master/CHANGELOG.md)
- [Commits](nodeca/js-yaml@4.1.1...4.2.0)

---
updated-dependencies:
- dependency-name: js-yaml
  dependency-version: 4.2.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [tar](https://github.com/isaacs/node-tar) from 7.5.11 to 7.5.16.
- [Release notes](https://github.com/isaacs/node-tar/releases)
- [Changelog](https://github.com/isaacs/node-tar/blob/main/CHANGELOG.md)
- [Commits](isaacs/node-tar@v7.5.11...v7.5.16)

---
updated-dependencies:
- dependency-name: tar
  dependency-version: 7.5.16
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* chore: onboard to ADO feed

* Fix relative path
Brings the fork up to date with upstream (fork point was Oct 2023):
- winpty support removed (deps/winpty deleted; Windows uses conpty only)
- NAPI-era native code with upstream's fd-leak, shutdown, and
  backpressure fixes; Buffer write API; pixel-size resize
- upstream's centralised loadNativeModule loader, extended here to
  find the fork's abi-tagged bundled prebuilds first
- modern toolchain: TypeScript 5, ESLint 10 flat config, node-gyp 11

Fork keeps: package identity, prebuild-install install chain, bundled
linux prebuilds, multiarch release workflows, engines range.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
All native loading now goes through loadNativeModule in utils.ts
(which handles the fork's abi-tagged bundled prebuilds); nothing
imports prebuild-loader any more.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@bwp91
bwp91 requested a review from NorthernMan54 as a code owner July 19, 2026 13:10
prebuild-install downloads the prebuild published for the current
package version during npm ci, so tests were running against the stale
v0.13.1 binary instead of the code in the checkout - the new fd-leak
regression tests correctly failed against it.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@bwp91
bwp91 force-pushed the sync/upstream-main branch from c8037bd to 8552f6f Compare July 19, 2026 15:49
Node.js (since the CVE-2024-27980 fix) refuses to spawn .cmd files
without shell: true, so the source-build fallback in scripts/install.js
crashed on any Windows machine with no matching prebuild - such as
win32-arm64, which has no published prebuilds.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@NorthernMan54
NorthernMan54 changed the base branch from main to alpha-0.15.0 July 24, 2026 13:15
dependabot Bot and others added 3 commits July 27, 2026 15:12
Bumps [tar](https://github.com/isaacs/node-tar) from 7.5.16 to 7.5.22.
- [Release notes](https://github.com/isaacs/node-tar/releases)
- [Changelog](https://github.com/isaacs/node-tar/blob/main/CHANGELOG.md)
- [Commits](isaacs/node-tar@v7.5.16...v7.5.22)

---
updated-dependencies:
- dependency-name: tar
  dependency-version: 7.5.22
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…-main

# Conflicts:
#	.npmignore
#	eslint.config.js
#	package-lock.json
#	package.json
#	src/windowsTerminal.test.ts
@bwp91
bwp91 requested a review from Copilot July 29, 2026 08:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review this pull request because it exceeds the maximum number of lines (20,000). Try reducing the number of changed lines and requesting a review from Copilot again.

@bwp91
bwp91 requested review from NorthernMan54 and removed request for NorthernMan54 July 29, 2026 10:37
@NorthernMan54
NorthernMan54 deleted the branch alpha-0.15.0 August 5, 2026 00:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.