Skip to content

feat: native promises, parallel pruning, skip on no-deploy#82

Open
KennethWKZ wants to merge 5 commits into
claygregory:masterfrom
KennethWKZ:feat/native-promises-parallel-pruning
Open

feat: native promises, parallel pruning, skip on no-deploy#82
KennethWKZ wants to merge 5 commits into
claygregory:masterfrom
KennethWKZ:feat/native-promises-parallel-pruning

Conversation

@KennethWKZ

Copy link
Copy Markdown

Motivation

Three quality-of-life improvements, none changing user-facing config:

1. Replace bluebird with native Promise

Native Promise is available everywhere now. All BbPromise.all/resolve/mapSeries/each/join usage is rewritten as async/await + Promise.all, and bluebird is removed from dependencies.

2. Skip pruning when the deployment was skipped

postDeploy now treats the noDeploy option robustly (boolean or string from the CLI) and logs that pruning is being skipped, instead of the previous strict === true check that silently returned.

3. Prune old versions in parallel

Function/layer version deletion was strictly sequential (BbPromise.each). It now runs through a tiny native pMap(items, mapper, concurrency) helper with concurrency 5 — bounded so the Lambda API call rate stays within normal limits, but many versions are deleted in parallel instead of one at a time. The outer per-function / per-layer loop stays sequential to keep progress output readable.

Side fix

deleteVersionsForFunction's Lambda@Edge guard now also recognizes the AWS SDK v3 error shape (e.$metadata.httpStatusCode + e.message), not only the legacy provider.request e.providerError shape — useful for frameworks that build SDK v3 clients (e.g. osls v4, see #81).

Verification

  • node --check index.js clean; bluebird fully removed.
  • pMap verified to preserve input order under bounded concurrency.
  • No behavior change to selection logic (selectPruneVersions*) or the public options.

osls v4 removed provider.request() (throws AWS_SDK_V2_SURFACE_REMOVED).
Route Lambda calls through lambdaRequest(): on osls v4 build a cached
LambdaClient from provider.getAwsSdkV3Config() and send the matching
<Method>Command; on serverless v3 keep the original provider.request()
path. LambdaClients are cached per provider via a WeakMap.

@aws-sdk/client-lambda added as a runtime dependency.
@KennethWKZ
KennethWKZ force-pushed the feat/native-promises-parallel-pruning branch from 46f1039 to 6af9109 Compare July 5, 2026 19:04
AWS SDK v3 Command classes are PascalCase (ListVersionsByFunctionCommand)
but the v2 provider.request action names are camelCase (listVersionsByFunction).
The previous lookup `${action}Command` resolved to undefined and threw
'Command is not a constructor'. Capitalize the action and guard against
unknown commands with a clear error.
@KennethWKZ
KennethWKZ force-pushed the feat/native-promises-parallel-pruning branch from 139dfa1 to bd5141a Compare July 5, 2026 19:19
- Drop bluebird in favor of native Promise: mapSeries/each/join chains
  rewritten as async/await + Promise.all. bluebird removed from deps.
- Parallelize old-version deletion with a small bounded-concurrency
  pMap helper (concurrency 5) instead of deleting one version at a time,
  keeping AWS Lambda API call rate within safe limits.
- Skip pruning when deployment was skipped: postDeploy now treats the
  noDeploy option robustly (boolean or string) and logs that prune is
  being skipped.
- deleteVersionsForFunction Lambda@Edge handling updated to also recognize
  AWS SDK v3 error shape (e. + e.message), not just the v2
  provider.request e.providerError shape.
@KennethWKZ
KennethWKZ force-pushed the feat/native-promises-parallel-pruning branch from bd5141a to e8bb37b Compare July 5, 2026 19:28
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.

1 participant