Skip to content

fix(dlp): lazy-load docx to silence localStorage warning on every command#218

Merged
cdot65 merged 1 commit into
cdot65:mainfrom
scthornton:fix/lazy-load-docx-localstorage-warning
May 28, 2026
Merged

fix(dlp): lazy-load docx to silence localStorage warning on every command#218
cdot65 merged 1 commit into
cdot65:mainfrom
scthornton:fix/lazy-load-docx-localstorage-warning

Conversation

@scthornton

Copy link
Copy Markdown
Contributor

What

Lazy-load the docx dependency so it only loads when DOCX output is actually generated.

Why

docx was imported eagerly in src/dlp/generate/docx.ts and src/dlp/embed/docx.ts. Because the command tree is built at startup, docx loaded on every airs command. Its bundled browserify polyfills pull in util-deprecate's browser shim, which reads localStorage at import time. On Node 22+ (seen on Node 25) that triggers:

(node:NNNN) Warning: `--localstorage-file` was provided without a valid path

so the warning printed on every command (scan, profiles, redteam, etc.), not just DLP file generation.

Fix

Defer the docx import into the DOCX builders via await import('docx'):

  • src/dlp/generate/docx.ts - import moved inside the (already-async) docx() builder.
  • src/dlp/embed/docx.ts - import moved inside build(); the technique embedders now pass plain data instead of pre-constructed Paragraphs, so no module-level docx reference remains.

docx (and the warning) now load only when dlp-gen actually produces DOCX. Unrelated commands are warning-free and start slightly faster.

Testing

  • pnpm build clean, pnpm lint (biome) clean
  • pnpm test: full unit suite passes
  • Verified airs runtime profiles list and runtime scan emit 0 localStorage warnings; dlp-gen DOCX output still works and the DOCX unit tests pass

Changeset included (patch).

@cdot65 cdot65 merged commit 2f20f2d into cdot65:main May 28, 2026
5 checks passed
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