Skip to content

Fix pug_debug_sources when includeSources contain Buffers - #3474

Open
Hashim1999164 wants to merge 1 commit into
pugjs:masterfrom
Hashim1999164:fix/debug-sources-buffer-tostring
Open

Hashim1999164 wants to merge 1 commit into
pugjs:masterfrom
Hashim1999164:fix/debug-sources-buffer-tostring

Conversation

@Hashim1999164

@Hashim1999164 Hashim1999164 commented Jul 22, 2026

Copy link
Copy Markdown

Summary

  • Convert includeSources values with .toString('utf8') in pug-code-gen so Node Buffers from fs.read serialize as strings for pug_rethrow.
  • Only embed sources for filenames assigned to pug_debug_filename, avoiding binary buffers in the generated debug map.

Fixes #3290

Test plan

  • Manual smoke test: compile with includeSources values as Buffers; runtime error includes source context instead of failing inside pug_rethrow.
  • Unused binary entries in includeSources are omitted from pug_debug_sources.
  • npx jest packages/pug/test/pug.test.js passes (including snapshots).

Convert includeSources values with toString('utf8') and only embed
sources for filenames assigned to pug_debug_filename, so pug_rethrow
always receives a string and binary buffers are not serialized.

Fixes pugjs#3290
@rollingversions

rollingversions Bot commented Jul 22, 2026

Copy link
Copy Markdown

pug (3.0.4 → 3.0.5)

Bug Fixes

  • Update pug-code-gen so debug sources work when includeSources contain Buffers

pug-code-gen (3.0.4 → 3.0.5)

Bug Fixes

  • Convert includeSources Buffer values to strings so debug rethrow receives source text

Packages With No Changes

The following packages have no user facing changes, so won't be released:

  • pug-attrs
  • pug-error
  • pug-filters
  • pug-lexer
  • pug-linker
  • pug-load
  • pug-parser
  • pug-runtime
  • pug-strip-comments
  • pug-walk

Edit changelogs

@Hashim1999164

Copy link
Copy Markdown
Author

Added the RollingVersions changelog for pug and pug-code-gen so this can ship as a patch. The RollingVersions check is green now.

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.

Generated debug_sources are node Buffers and fail pug_rethrow

1 participant