Skip to content

Conversation

cnrudd
Copy link
Member

@cnrudd cnrudd commented Sep 18, 2025

The bugs below were caused by a circular dependency issue.

image image

It took a lot of trial and error to identify the cause, but ultimately it was determined to be these changes:
99264e3#diff-0e3d75d14bd9d478ce2a63d57efd6d7dfdc9fc3fcfce7598e187db141e5f1358R8

99264e3#diff-059e005c44af2ebad384deb53208cf43a0b35c787da98e4b39b4164ea4292354R8

where the import path of checkVersion was changed from
import {checkVersion} from '@xh/hoist/utils/js/VersionUtils';
to the less specific:
import {checkVersion, logError} from '@xh/hoist/utils/js';

How we resolved the bug:

The Version Utils were moved into their own directory and 'unlinked' from other libs because they are called very early in the runtime cycle. If other libs are linked to them via index.ts, it looks like "PORTIONS" of the other libs get called in, and then the other libs do not get loaded again, which is why we were seeing many "undefined" and "not initialized" errors in the client.

After this VersionUtils problem was solved, another circDep issue came up, between LogUtils and LangUtils.
We decided to remove the one dependency LogUtils had on LangUtils by duplicating the interspersed method in LogUtils.

The lesson I took from this is that circular dependency risk can be reduced by isolating libs that are loaded/used very early in the runtime cycle.
By isolating I mean:

  1. Not putting them into index.ts files with other libs
  2. Reducing their dependency on other libs that themselves extend the dependency web.

VersionUtils and LogUtils are both examples of libs with methods that we want to call early in the app startup/run time start up, so, we have moved them into their own packages and removed any dependencies on other packages in the framework.

Corresponding Toolbox PR with required import path changes:

xh/toolbox#778

Hoist P/R Checklist

Pull request authors: Review and check off the below. Items that do not apply can also be
checked off to indicate they have been considered. If unclear if a step is relevant, please leave
unchecked and note in comments.

  • Caught up with develop branch as of last change.
  • Added CHANGELOG entry, or determined not required.
  • Reviewed for breaking changes, added breaking-change label + CHANGELOG if so.
  • Updated doc comments / prop-types, or determined not required.
  • Reviewed and tested on Mobile, or determined not required.
  • Created Toolbox branch / PR, or determined not required.

If your change is still a WIP, please use the "Create draft pull request" option in the split
button below to indicate it is not ready yet for a final review.

Pull request reviewers: when merging this P/R, please consider using a squash commit to
collapse multiple intermediate commits into a single commit representing the overall feature
change. This helps keep the commit log clean and easy to scan across releases. PRs containing a
single commit should be rebased when possible.

@cnrudd cnrudd requested review from lbwexler and amcclain September 18, 2025 17:30
Copy link
Member

@amcclain amcclain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for continuing to work through this!

  • Could we summarize - for this PR + resulting squash commit message - what was going wrong here? So we have some record of what we've learned and how this resolves?
  • How could we document that in the code in any way?
  • Would be answered by above, but why did VersionUtils also need to move?

@lbwexler lbwexler closed this Sep 19, 2025
@lbwexler lbwexler deleted the circularDepFix branch September 21, 2025 22:57
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.

3 participants