Solve circular dependency issue between workflow/constants.ts
file and default.ts
file
#13165
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
there is a lurking bug in the web code caused by a circular dependency issue.
the problem is that
web/app/components/workflow/nodes/if-else/default.ts
(and other default files) imports fromweb/app/components/workflow/constants.ts
, and the latter imports from the former values to populate theNODES_EXTRA_DATA
object.if
default.ts
file is imported first, thennodeDefault
will be defined, which means whenconstants.ts
is imported, the code that populates theNODES_EXTRA_DATA
object will be able to read values fromnodeDefault
because it is defined.when
constants.ts
is imported beforedefault.ts
, the former will try to import from the latter, and this time ancannot read property of undefined
error message will be thrown becausenodeDefault
isn't defined yet.right now the order of resolution runs
default.ts
, which causes no problems, but it might change when adding new dependencies, which is what makes this PR a prerequisite to #13166, because importingPromptEditor
inForm.tsx
changed the order of resolution in a way that broke the app with the error message:cannot read property of undefined
.Checklist
Important
Please review the checklist below before submitting your pull request.
dev/reformat
(backend) andcd web && npx lint-staged
(frontend) to appease the lint gods