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

Fix pug_debug_sources when includeSources contain Buffers#3474
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

Copy link
Copy Markdown

There is no change log for this pull request yet.

Create a changelog

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