herbsjs / buchu

Use Cases - Uniform, auditable and secure use case library
Other
24 stars 22 forks source link

Lack of treatment for circular structures #46

Closed KelvinFelix closed 3 years ago

KelvinFelix commented 3 years ago

Describe the bug The Step class uses JSON.stringify without the callback function to handle circular structures. When passing an object with a circular structure it shows the error "TypeError: Converting circular structure to JSON" and interrupts code execution.

To Reproduce Steps to reproduce the behavior:

  1. Create a usecase and use the step method on it.
  2. Create an object with a circular structure, for example by creating a spreadsheet with exceljs.
  3. Try passing the created spreadsheet from one step to another inside usecase
  4. See the error TypeError: Converting circular structure to JSON --> starting at object with constructor 'Worksheet' | property '_rows' -> object with constructor 'Array' | index 0 -> object with constructor 'Row' --- property '_worksheet' closes the circle

Expected behavior The Setp class should perform the packaging of objects with circular structures.

Screenshots Object with circular reference image

The output error image

Additional context n/a

KelvinFelix commented 3 years ago

The issue was fixed and is placed in the last buchu's version. If you prefer, you can see the adjustment pull request here: https://github.com/herbsjs/buchu/pull/47.