-
Notifications
You must be signed in to change notification settings - Fork 354
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
fix: datasourceMap is empty when init set schema #1142
base: develop
Are you sure you want to change the base?
Conversation
WalkthroughThe pull request reorganizes the subscription logic within the Changes
Suggested labels
Suggested reviewers
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure. 🔧 ESLint
packages/canvas/render/src/RenderMain.tsOops! Something went wrong! :( ESLint: 8.57.1 ESLint couldn't find the plugin "@typescript-eslint/eslint-plugin". (The package "@typescript-eslint/eslint-plugin" was not found when loaded as a Node module from the directory "/packages/canvas".) It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:
The plugin "@typescript-eslint/eslint-plugin" was referenced from the config file in "packages/canvas/.eslintrc.cjs » @vue/eslint-config-typescript". If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team. ✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/canvas/render/src/RenderMain.ts (1)
210-222
: LGTM! Moving subscriptions after dataSource watch setup fixes the initialization issue.The changes ensure that dataSourceMap is properly initialized before the schemaImport listener is triggered, resolving the reported bug.
Consider adding a guard check for dataSourceMap in the schemaImport callback to make the code more resilient:
window.host.subscribe({ topic: 'schemaImport', subscriber: 'canvasRenderer', callback: () => { + if (!getDataSourceMap()) { + console.warn('dataSourceMap is not initialized yet'); + return; + } setSchema(window.host.getSchema()) } })
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/canvas/render/src/RenderMain.ts
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: push-check
English | 简体中文
PR
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
Background and solution
一句话描述:修复页面初始化时,页面加载 dataSourceMap 提示 undefined 的 bug。 #1138
【问题复现描述】
看到报错:
【问题分析】
schemaImport
监听会立即触发回调。导致 dataSourceMap 还没有被初始化,就被调用了。【解决方案】
schemaImport
事件的监听放到dataSource
的 watch 函数后面。由于
dataSource
是immediate
的监听,所以也会立即执行,确保 dataSourceMap 提前构建。What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information
Summary by CodeRabbit