-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: tts node and stt node add warning #1953
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -172,8 +172,12 @@ const modelOptions = ref<any>(null) | |
| const providerOptions = ref<Array<Provider>>([]) | ||
|
|
||
| const aiChatNodeFormRef = ref<FormInstance>() | ||
| const nodeCascaderRef = ref() | ||
| const validate = () => { | ||
| return aiChatNodeFormRef.value?.validate().catch((err) => { | ||
| return Promise.all([ | ||
| nodeCascaderRef.value ? nodeCascaderRef.value.validate() : Promise.resolve(''), | ||
| aiChatNodeFormRef.value?.validate() | ||
| ]).catch((err: any) => { | ||
| return Promise.reject({ node: props.nodeModel, errMessage: err }) | ||
| }) | ||
| } | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are no critical errors in the provided code. However, I suggest adding error handling to ensure that the const modelOptions = ref<any>(null);
const providerOptions = ref<Array<Provider>>([]);
const aiChatNodeFormRef = ref<FormInstance>();
const nodeCascaderRef = ref();
function validate(): Promise<{ message?: string }> {
return Promise.race([
(async () => await (nodeCascaderRef.value && nodeCascaderRef.value.validate()))(),
(async () => await (aiChatNodeFormRef.value && aiChatNodeFormRef.value.validate()))()
])
.catch((err) => ({ message: err }));
}Key Changes:
This approach ensures that both validators run concurrently, but stops execution on the first successful result or the first error encountered. |
||
|
|
||
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.
The provided code is mostly correct, but there are a few improvements that can be made:
Avoid Using Await with
Promise.all: The use ofawaitinside the catch block will prevent further execution after an error. Replace it with.then()to continue processing.Ensure Cascader Validations: Ensure that cascader validations handle cases where the reference might not exist (as it does now).
Here's the revised version of the code:
Key Changes:
new Promise.nodeCascaderRefasnull. This ensures we don't rely on optional chaining (?) unnecessarily and avoids potential runtime errors.initializeFormAndCascade, which uses Vue'sonMountedhook to ensure that any necessary initialization logic runs once the component has mounted.This should address most performance concerns and improve stability.