Uh oh!
There was an error while loading. Please reload this page.
fix: app:pack aborts when Node writes process warnings to api-mesh stderr - #931
Open
raj-prince587 wants to merge 1 commit into
Open
Conversation
…derr
`createDeployYamlFile` treats any output on the `aio api-mesh get --json`
child's stderr as a fatal error. Node process warnings (e.g. DEP0040, the
punycode deprecation emitted on Node 22) are written to stderr while the
command exits 0, so `app:pack` aborts on a successful mesh lookup with the
deprecation notice presented as the error.
The stderr channel is still used to detect the "no mesh found" case, since
the api-mesh plugin reports it via `this.error(msg, { exit: false })` which
writes to stderr and exits 0. Rather than removing that check, Node process
warnings are suppressed in the child via NODE_NO_WARNINGS and any that still
reach stderr are stripped before the check. NODE_NO_WARNINGS is used instead
of NODE_OPTIONS so a user-set NODE_OPTIONS is preserved.
Also fixes an unguarded property access in the same catch block: `err?.message`
stops one level short, so a thrown value without a `message` (a non-Error
throw, or an execa error carrying output only on `stderr`) raised a TypeError
inside the catch and masked the original failure. The existing test asserted
that TypeError as expected behaviour; it now asserts that the "no mesh"
message on `stderr` is recognised. Error details now go to aioLogger.debug
instead of console.error, which double-reported since `err` is rethrown.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>raj-prince587
marked this pull request as ready for review
August 7, 2026 08:46
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
createDeployYamlFiletreats any output on theaio api-mesh get --jsonchild's stderr as a fatal error:Node process warnings go to stderr while the command still exits
0. On Node 22 thepunycodedeprecation (DEP0040) is emitted on virtually everyaioinvocation, so a successful mesh lookup abortsapp:pack, surfacing the deprecation notice as the error.Importantly, the
if (stderr) throwis not redundant and is deliberately kept: it is how the "no mesh" case is detected, becauseapi-mesh:getreports that viathis.error(msg, { exit: false })— which writes to stderr and exits0. So instead of removing the check, this PR keeps it and removes only the noise:NODE_NO_WARNINGS: '1'to the child, suppressing Node process warnings at the source.NODE_NO_WARNINGSis used rather thanNODE_OPTIONSso that a user-setNODE_OPTIONSis preserved (execa mergesenvwithprocess.envby default).(node:NNN) …/(Use `node --trace-…`)lines via a smallstripNodeWarningshelper, as a backstop for warnings arriving from a wrapper or--requirepreload.Behaviour is otherwise unchanged — genuine api-mesh errors still abort
app:packexactly as before.Secondary fix in the same block
The optional chaining stops one level short: a thrown value with no
message(a non-Errorthrow, or an execa error carrying output only onstderr) raisesTypeError: Cannot read properties of undefined (reading 'includes')inside the catch, masking the original failure. It now inspectsmessageandstderr, so a "no mesh" report is recognised however it arrives, and anything unrecognised is rethrown untouched.console.error(err)is replaced withaioLogger.debug— it bypassed the logger used everywhere else in the file and double-reported, sinceerris rethrown on the next line.The
'Error: 'prefix was also dropped from the matched substring so the check doesn't depend on oclif's error styling.Related Issue
Fixes#930
Motivation and Context
app:packis currently unusable on Node 22 for any project where the api-mesh plugin is installed, which is the default in recent@adobe/aio-clireleases. The failure is confusing because the reported error is a deprecation warning rather than anything to do with packaging.How Has This Been Tested?
npx jest -c jest.config.js test/commands/app/pack.test.js— 35 passed, withpack.jsat 100% statements/branches/functions/lines (the repo's global threshold).npx eslint src testis clean.One existing test is updated. It asserted the
TypeErrorabove as expected behaviour:The mocked throw carries
stderr: 'Error: Unable to get mesh config. No mesh found for Org'— a "no mesh" report — so it now asserts that the no-meshdeploy.yamlfixture is written instead of the command crashing.Three tests are added:
NODE_NO_WARNINGSasserted on the execa optionsmessagenorstderr→ original value rethrown, noTypeErrorThe existing
api-mesh service is unavailableandno api-meshtests pass unmodified, which is the main guard that error semantics are unchanged.Verified end-to-end against a real App Builder project on Node v22.22.2: before the change
app:packaborted with theDEP0040notice; after it, the mesh lookup no longer misreports the warning as a failure.Types of changes
Checklist:
One question for maintainers
Should a genuine api-mesh failure abort
app:packat all?meshConfigis optional indeploy.yaml, yet an unrelated auth/org problem currently fails the entire packaging step even for apps with no mesh. I hit this withUser does not belong to the organization.on a project that doesn't use api-mesh — under--json, oclif serialises that to{"error":{"oclif":{"exit":2}}}, so the message needed for classification is lost entirely.I've deliberately left that behaviour alone here to keep this PR a pure bug fix. Happy to follow up with a separate PR making the lookup non-fatal (warn and continue) if that's the direction you'd prefer.
🤖 Generated with Claude Code