Skip to content

fix: stop passing the command result to flush as its timeout - #859

Open
obarcelonap wants to merge 1 commit into
adobe:masterfrom
obarcelonap:fix-flush-nan-timeout
Open

obarcelonap wants to merge 1 commit into
adobe:masterfrom
obarcelonap:fix-flush-nan-timeout

Conversation

@obarcelonap

Copy link
Copy Markdown
Member

Description

bin/run chains .then(flush), so whatever the command's run() resolves with is passed to flush(ms) as its timeout. Any command that returns a value (e.g. with --json) ends up calling setTimeout with NaN, and Node prints a TimeoutNaNWarning on every invocation. This change calls flush() without arguments so the default timeout is used.

Related Issue

No open issue. This is a regression from 60ecc16, which changed .then(() => require('@oclif/core/flush')) (from eae716a) to .then(flush). Happy to open an issue if preferred.

Motivation and Context

Reproduce with aio plugins --json (or any plugin command whose run() returns a value):

(node:12345) TimeoutNaNWarning: NaN is not a number.
Timeout duration was set to 1.

Besides the noise, flush effectively runs with a 1 ms timeout instead of its 10 s default.

How Has This Been Tested?

  • Added an e2e test that runs bin/run plugins --json and asserts stderr has no TimeoutNaNWarning; it fails without the fix and passes with it.
  • npm test (unit tests and lint) passes.
  • Manually ran aio plugins --json with the patched bin/run; the warning is gone.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@codecov

codecov Bot commented Dec 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

iivvaannxx added a commit to adobe-commerce/aio-cli-plugin-commerce that referenced this pull request Dec 3, 2026
aio-cli 11.2.0's bin/run does run().then(flush), so a command's result
becomes oclif flush's timeout: Node warns about a NaN timeout and flush
gives up after 1 ms, which can cut off large piped output. Commands now
hand nothing back once oclif has printed the result. The test fixture
ends like aio's bin/run. Remove once adobe/aio-cli#859 is released.
iivvaannxx added a commit to adobe-commerce/aio-cli-plugin-commerce that referenced this pull request Dec 3, 2026
* Move the instance commands into a bundled workspace package

The instance commands become the private oclif plugin
@adobe-commerce/aio-cli-plugin-commerce-instance in packages/, bundled into
the facade like the extensibility plugin (dependencies, bundledDependencies,
oclif.plugins). Each command is a folder under source/commands with the
command in index.ts and the files only it uses beside it; source/lib keeps
the code shared by more than one command. The build maps each command folder
to dist/commands/commerce/instance/<id>/index.mjs, so the command ids stay
the same. Imports in source and tests go through the package's subpath
imports (#* for source, #test/* for tests).

The root build and tests run across the workspace with vp run -r.

* Move the manifest script into a scripts workspace package

scripts/ becomes the private workspace package @adobe-commerce/scripts with
the plugin-prepack and plugin-postpack bins, as the SDK's scripts package
does. plugin-prepack writes the oclif manifest of the package it runs in and
of every plugin that package lists in oclif.plugins, so a newly bundled
plugin gets its manifest without editing the script; plugin-postpack removes
them. Plugin roots are resolved to their real path, so a plugin that pnpm
links into node_modules keeps relative command paths in its manifest.

* Document the workspace packages in AGENTS.md

New code goes into new packages that follow the conventions and this repo's
lint, format and test setup, not into the legacy extensibility package. Each
command is a folder with its index.ts, and lib/ holds only code shared by more
than one command. Packages may import from each other as workspace:*
dependencies, and every import inside a package, source and tests, goes
through its subpath imports.

* Keep each rule in one file

conventions.md drops the code-structure rules (no shared package, plugins
don't import from each other, the base command applies the contract): how
the code is organized lives in AGENTS.md, which now lets packages depend on
each other. It keeps the runtime rule that plugins never run each other's
commands. The sections after the removed one are renumbered.

AGENTS.md drops its second pointer to conventions.md and links to
CONTRIBUTING.md for changesets instead of restating them, and gains the rule
that each rule lives in one file that the others link to.

* Share one TypeScript config across the workspace

configs/typescript is the private package @adobe-commerce/config-typescript
with the compiler options every package used to repeat, as the SDK's
configs/typescript does. The root, the instance plugin and scripts extend
its tsconfig.base.json and only list what they include. Format and lint stay
global, in the root vite.config.ts.

* Share dependency ranges through the pnpm catalog

Every dependency range of the root, the instance plugin and scripts moves to
the catalog in pnpm-workspace.yaml, and the packages use catalog:. The
lockfile resolves the same versions. The legacy extensibility package keeps
its own ranges.

pnpm resolves catalog: and workspace: ranges only in the package it packs,
so the bundled instance plugin reached the tarball with them and npm refused
to install it. plugin-prepack now also writes each bundled plugin's
package.json as pnpm would publish it (real ranges, no dev dependencies,
which npm reads too), keeping the original as package.json.orig, and
plugin-postpack puts it back.

AGENTS.md says ranges live in the catalog and every package extends the
shared TypeScript config.

* Base the shared TypeScript config on the SDK's

configs/typescript now has the SDK base config's shape: it extends
@tsconfig/recommended, @tsconfig/node-lts and @tsconfig/node-ts, uses
ESNext with bundler resolution, and includes every .ts file under the
extending config's folder, so a package's tsconfig.json is only the extends.
It keeps two checks the facade code already passes on top of the SDK's:
noUncheckedIndexedAccess and noImplicitOverride.

* Make tooling a workspace package

tooling/ becomes the private package @adobe-commerce/tooling, like
scripts/: the source-header lint plugin in source/, its test in test/, and
an export the root vite.config.ts loads by package name. The root keeps no
code or tests of its own; its test script only runs every package's tests.

* Keep only shared dependency ranges in the catalog

A dependency that more than one package uses takes its range from the
catalog. Any other keeps its range in the one package that uses it.

* Drop the empty changeset rule

Only a pull request that affects users needs a changeset.

* Move the extensibility plugin into legacy/

legacy/ holds the packages kept as they were before the rewrite, so the
lint, format and knip setup ignore one folder instead of each package.

* Pin Node in .nvmrc and drop .npmrc

.npmrc only set tag-version-prefix, which npm version reads. Nothing runs
npm version: changesets versions and tags the package.

* Document the tag changesets pushes in a workspace

In a pnpm workspace, changesets tags a release as <name>@<version>, not
v<version>.

* Work around aio-cli passing the command result to flush

aio-cli 11.2.0's bin/run does run().then(flush), so a command's result
becomes oclif flush's timeout: Node warns about a NaN timeout and flush
gives up after 1 ms, which can cut off large piped output. Commands now
hand nothing back once oclif has printed the result. The test fixture
ends like aio's bin/run. Remove once adobe/aio-cli#859 is released.

* Move legacy/ inside packages/

The legacy extensibility plugin is now in packages/legacy/, next to the
other plugins the facade bundles.
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.

2 participants