Skip to content

Circular reference in JSON during VSCode's stringify of Job nodes #2121

@traeok

Description

@traeok

Describe the bug

In the latest release of VSCode (1.75), a change was introduced to tree view management, which breaks our handling of job nodes. In 1.75, when clicking on a job that is contained within a session, the circular JSON error will appear as an error dialog. This is because the session node has a children array, and that array contains nodes with a reference back to their parent (mParent). Since VScode now uses JSON.stringify during tree view management, circular references will introduce an error in JSON.stringify and execution halts as a result. (This is currently an uncaught exception on VScode's behalf)

While the exception is being caught, this breaks functionality with the job nodes as they are no longer expanded when clicking on the node itself. The only way to collapse or expand the node at that point is to use the chevron beside the node.

To Reproduce

  1. Enter in a job search query.
  2. Submit said query.
  3. Observe list of jobs that appear in the tree view.
  4. Select one of the jobs in your active session node.

Expected behavior

The job node should collapse or expand without any errors (typical tree node functionality).

Screenshots

(uploading GIF)

Desktop (please complete the following information):

  • OS: Windows 10
  • Zowe Explorer Version: 2.6.0

Additional context

I've thought of a few temporary workarounds (in case the issue is not addressed right away within VScode) that can avoid this issue:

  • Global node map:
    • One global, generic map:
      • Avoids extra structural overhead
      • Involves type casting and working around interfaces/generics
    • Map for each tree view:
      • More structural overhead
      • Avoids type casting as the type matches the tree view
    • Note: either of these options will also help clean up favorites management, see More efficient data structure for favorites #2026
  • mParent as node label
    • This breaks the circular reference at the child level, as the parent property would be the label for the parent node, rather than the node reference itself.
    • This would involve making some adjustments to the usage of mParent in ZoweJobsNode.
  • children as string[]
    • This breaks the circular reference at the parent level, as the children are now strings referencing the child nodes, rather than the node reference itself.
    • This would involve making some adjustments to the usage of children in ZoweJobsNode, and may involve significant changes to how the tree is built.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions