Skip to content

Conversation

@7amed3li
Copy link

This PR adds lightweight stats tracking for pacote.extract by injecting a tracked extract function.
This helps identify slow package extractions and potential bottlenecks during scans.

No breaking changes - existing code works as-is.

Closes #615

@changeset-bot
Copy link

changeset-bot bot commented Jan 29, 2026

🦋 Changeset detected

Latest commit: 468dd7a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@nodesecure/tarball Minor
@nodesecure/scanner Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@clemgbld clemgbld requested a review from fraxken January 30, 2026 00:10
};
}

type ExtractFunction = (
Copy link
Member

Choose a reason for hiding this comment

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

i would rename it PacoteProvider and use an interface with the method extract

pacoteProvider: {
extract: async(spec: string, dest: string, opts: pacote.Options) => {
await statsCollector.track(
`pacote.extract[${spec}]`,
Copy link
Member

Choose a reason for hiding this comment

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

pacote.extract[${spec}] -> pacote.extract ${spec}

It’s the same pattern in the two other examples

@7amed3li 7amed3li force-pushed the feat/stats-tracking-pacote-extract branch from 02daaed to 3483f28 Compare January 30, 2026 13:00

const pacoteProvider: PacoteProvider = {
extract: async(spec, dest, opts) => {
await statsCollector.track(
Copy link
Member

Choose a reason for hiding this comment

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

You don’t need the async await syntax since you don’t need the awaited result in this function

spec: string,
destination: string,
options: pacote.Options
): Promise<any>;
Copy link
Member

Choose a reason for hiding this comment

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

The retuned type should be the same returned type than pacote.extract or void but not any

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.

Add stats tracking on pacote.extract through extractAndResolve

2 participants