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

Solve circular dependency issue between workflow/constants.ts file and default.ts file #13165

Merged
merged 1 commit into from
Feb 4, 2025

Conversation

obadakhalili
Copy link
Contributor

@obadakhalili obadakhalili commented Feb 3, 2025

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 from web/app/components/workflow/constants.ts, and the latter imports from the former values to populate the NODES_EXTRA_DATA object.

if default.ts file is imported first, then nodeDefault will be defined, which means when constants.ts is imported, the code that populates the NODES_EXTRA_DATA object will be able to read values from nodeDefault because it is defined.

when constants.ts is imported before default.ts, the former will try to import from the latter, and this time an cannot read property of undefined error message will be thrown because nodeDefault 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 importing PromptEditor in Form.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.

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. ☕️ typescript Pull request that update TypeScript code. labels Feb 3, 2025
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Feb 4, 2025
@crazywoola crazywoola merged commit 8fbc9c9 into langgenius:main Feb 4, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files. ☕️ typescript Pull request that update TypeScript code.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants