coze-studio icon indicating copy to clipboard operation
coze-studio copied to clipboard

请问工作流组件"插件"的超时时间哪里改呢?

Open icejean opened this issue 1 year ago • 4 comments

我要改的是”插件“组件,而不是http组件,参考#issue286,我可以改http组件的默认超时限制,但我在frontend/packages/workflow/playground/src/node-registries/plugin目录下,找不到有定义”插件“组件最大超时3分钟的地方,那里没有http组件一样的form-render.tsx文件,应该是继承自其它地方,请问要改哪呢? 我的应用场景要调用一些耗时较长的插件,需要增加最大超时时间,参考#issue456, 我知道后端已经取消了所有的超时限制,但前端有些地方没有改,比如http组件,还有plugin组件。

icejean avatar Aug 07 '25 23:08 icejean

这个问题暂时这样绕过,修改frontend/packages/workflow/playground/src/form-extensions/components/setting-on-error/components/timeout/index.tsx,handleChange()与handleBlur(),屏蔽掉max的检查:

/*
 * Copyright 2025 coze-dev Authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/* eslint-disable @typescript-eslint/no-magic-numbers */
import { useEffect, useState, type FC } from 'react';

import { useTimeoutConfig } from '@coze-workflow/nodes';
import { logger } from '@coze-arch/logger';
import { Input } from '@coze-arch/coze-design';

import { type SettingOnErrorItemProps } from '../../types';

// Millisecond to second (intelligently removes ending zeros)
const msToSeconds = (ms: number) => {
  const formatter = new Intl.NumberFormat('en-US', {
    maximumFractionDigits: 3,
    minimumFractionDigits: 0,
  });
  return formatter.format(ms / 1000);
};

/**
 * timeout
 */
export const Timeout: FC<SettingOnErrorItemProps<number>> = ({
  value,
  onChange,
  readonly,
}) => {
  const timeoutConfig = useTimeoutConfig();
  const [inputValue, setInputValue] = useState('');

  // Back-end millisecond to front-end second display
  useEffect(() => {
    const seconds = msToSeconds(value ?? timeoutConfig.default);
    setInputValue(seconds);
  }, [timeoutConfig.default, value]);

  // Handling input changes
  const handleChange = (v: string | number) => {
    const rawValue = String(v);
    // Limit input format: allow numbers and decimal points, up to three decimal places
    // if (/^\d*\.?\d{0,3}$/.test(rawValue)) {
    //  setInputValue(rawValue);
    // }
    setInputValue(rawValue);
  };

  // Converted to milliseconds when submitting
  const handleBlur = () => {
    try {
      // let ms = Math.round(Number(inputValue) * 1000);
      //Added by Jean 2025/8/8 , delete "," in string number
      const str = String(inputValue);
      const result = str.replace(/,/g, '');
      let ms = Math.round(Number(result) * 1000);

      if (inputValue === '') {
        ms = timeoutConfig.default;
      }

      if (ms < timeoutConfig.min) {
        ms = timeoutConfig.min;
      }

      //if (ms > timeoutConfig.max) {
      //  ms = timeoutConfig.max;
      //}

      onChange?.(ms);

      // echo normalized value
      const seconds = msToSeconds(ms);
      setInputValue(seconds);
    } catch (err) {
      logger.error(err);
    }
  };

  if (timeoutConfig.disabled) {
    return <div>-</div>;
  }

  return (
    <Input
      size="small"
      data-testid="setting-on-error-timeout"
      value={inputValue}
      onChange={handleChange}
      onBlur={handleBlur}
      disabled={readonly}
      suffix="s"
    />
  );
};

icejean avatar Aug 08 '25 10:08 icejean

谢谢大佬

MoonS11 avatar Sep 17 '25 02:09 MoonS11

网页端的coze怎么改啊,我想搞一个sora的插件,但总是超时,我应该如何应对

Focalors-ai-bot avatar Oct 09 '25 05:10 Focalors-ai-bot

packages/workflow/nodes/src/setting-on-error/constants.ts

timeout: { default: 3 * 60 * 1000, max: 10 * 60 * 1000, },

应该改max的值就可以

Lvesfzzy avatar Jun 01 '26 07:06 Lvesfzzy