Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stack overflow error when using LocalDate #21

Merged
merged 1 commit into from
May 11, 2020
Merged

Conversation

pewniak747
Copy link
Contributor

Problem:

Attempting to format LocalTime instance obtained from a DICOM file with js-joda DateTimeFormatter results in a stack overflow error:

import { DateTimeFormatter } from "js-joda"

const time = elements.timeByTag(Tag.StudyTime)
time.format(DateTimeFormatter.ofPattern('HH:mm'))
      RangeError: Maximum call stack size exceeded                                                                                                                                              
          at <Jasmine>                                                                                                                                                                          
          at ZonedDateTime.getLong (http://localhost:9876/_karma_webpack_/node_modules/js-joda/dist/js-joda.esm.js:8047:1)                                                                      
          at ChronoField.getFrom (http://localhost:9876/_karma_webpack_/node_modules/@exini/dicom-streams-js/web/index.js:8709:1)                                                               
          at ZonedDateTime.getLong (http://localhost:9876/_karma_webpack_/node_modules/js-joda/dist/js-joda.esm.js:8058:1)                                                                      
          at ChronoField.getFrom (http://localhost:9876/_karma_webpack_/node_modules/@exini/dicom-streams-js/web/index.js:8709:1)                                                               
          at ZonedDateTime.getLong (http://localhost:9876/_karma_webpack_/node_modules/js-joda/dist/js-joda.esm.js:8058:1)                                                                      
          at ChronoField.getFrom (http://localhost:9876/_karma_webpack_/node_modules/@exini/dicom-streams-js/web/index.js:8709:1)                                                               
          at ZonedDateTime.getLong (http://localhost:9876/_karma_webpack_/node_modules/js-joda/dist/js-joda.esm.js:8058:1)                                                                      
          at ChronoField.getFrom (http://localhost:9876/_karma_webpack_/node_modules/@exini/dicom-streams-js/web/index.js:8709:1)                                                               
          at ZonedDateTime.getLong (http://localhost:9876/_karma_webpack_/node_modules/js-joda/dist/js-joda.esm.js:8058:1)                                                                      
          at ChronoField.getFrom (http://localhost:9876/_karma_webpack_/node_modules/@exini/dicom-streams-js/web/index.js:8709:1)                                                               

Cause:

dicom-streams-js bundles its own copy of js-joda package. The time instances returned from dicom-streams-js functions are constructed using that copy. These instances don't recognize js-joda objects that are loaded by the consumer of dicom-streams-js (like DateTimeFormatter). Effectively, two copies of js-joda are loaded, and they are not interoperable.

Solution:

Don't include a copy of js-joda in the bundle. The consumer of dicom-streams-js should be responsible for installing it. This should happen automatically since js-joda is declared as a dependency in package.json

@karl-exini karl-exini merged commit 77364a2 into develop May 11, 2020
@karl-exini karl-exini deleted the bugfix/js-joda branch March 24, 2021 11:51
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.

None yet

2 participants