Skip to content

fix(legacy): skip the value length of command group elements in AsyncDicomReader - #640

Merged
wayfarer3130 merged 1 commit into
1.0-betafrom
fix/1.0-beta-async-reader-skip-length
Nov 12, 2026
Merged

wayfarer3130 merged 1 commit into
1.0-betafrom
fix/1.0-beta-async-reader-skip-length

Conversation

@wayfarer3130

Copy link
Copy Markdown
Contributor

Summary

This PR ports the fix of #597 to the 1.0-beta branch. Iman974 found the defect and wrote the fix in #597.

Problem

AsyncDicomReader.read() skips the value of two types of element:

  • a command group element (0000,xxxx)
  • the DataSetTrailingPadding element (FFFC,FFFC)

The reader called stream.increment(tagObj.length). The Tag class has no length property, so the stream offset became NaN. The read loop compares the offset with a limit, and a comparison with NaN is always false. Thus the read stopped without an error, and the reader lost all tags after that element.

Change

  • packages/legacy/src/AsyncDicomReader.js: the reader uses length from the tag header, and not tagObj.length.
  • test/issues/pr597-async-reader-skip.test.js: a new test writes a file with a (0000,0002) element. The test checks that the async reader skips that element, and reads Rows and PixelData after it.

Tests

  • The new test fails without the fix, and passes with the fix.
  • test/async-data.test.js, test/sync-async-parser-equivalency.test.js, and test/issues/ pass: 123 passed, 10 skipped.
  • Prettier and ESLint pass on the two files.

Related: #597

🤖 Generated with Claude Code

…DicomReader

AsyncDicomReader skipped a (0000,xxxx) element or DataSetTrailingPadding
with stream.increment(tagObj.length). Tag has no length property, so the
stream offset became NaN and the read stopped silently, which dropped all
tags after that element. Use the value length from the tag header.

Port of #597 to 1.0-beta.

Co-authored-by: Iman Toumi <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@wayfarer3130
wayfarer3130 marked this pull request as ready for review November 12, 2026 15:00
@wayfarer3130
wayfarer3130 merged commit d711819 into 1.0-beta Nov 12, 2026
4 checks passed
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 1.0.0-beta.12 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant