YMFE / yapi

YApi 是一个可本地部署的、打通前后端及QA的、可视化的接口管理平台
http://yapi.smart-xwork.cn/
Apache License 2.0
27.32k stars 4.78k forks source link

1.10.2设置全局mock报错,请问需要检查哪些地方? #2536

Open quicklearning123 opened 2 years ago

quicklearning123 commented 2 years ago

版本号

~ 版本: 1.10.2 部署方式,docker,docker-YApi

在官网也是一样的现象: http://yapi.smart-xwork.cn/project/148166/setting

请问大家都是以什么姿势使用的?

什么问题

~ 1. 设置高级/全局mock脚本,调用接口报错

  1. 关闭高级/全局mock,返回字段有时候缺失部分字段(考验代码健壮性???),数组一直空。
[json-schema-faker] calling JsonSchemaFaker() is deprecated, call either .generate() or .resolve()
error: Error: Method Promise.prototype.then called on incompatible receiver [object Object]
    at Safeify.handleScriptResult (/yapi/vendors/node_modules/safeify/lib/Safeify.js:189:34)
    at Safeify.handleScriptDone (/yapi/vendors/node_modules/safeify/lib/Safeify.js:178:14)
    at Safeify.onWorkerDone (/yapi/vendors/node_modules/safeify/lib/Safeify.js:164:14)
    at ChildProcess.Safeify.onWorkerMessage (/yapi/vendors/node_modules/safeify/lib/Safeify.js:55:33)
    at ChildProcess.emit (events.js:310:20)
    at emit (internal/child_process.js:876:12)
    at processTicksAndRejections (internal/process/task_queues.js:85:21)

“期望”是生效的,但高级mock的脚本和全局脚本会报错: image

谁能告诉我怎么写脚本?

尝试过下面这些 参考 #1048 image

image image image

如何复现此问题

~ 必现

什么浏览器

~ chrome

什么系统(Linux, Windows, macOS)

mac

quicklearning123 commented 2 years ago

开启全局mock后,mock api报错,尝试的方案:

  1. 开启后无变化,参考 #2478 修改后报错2
  2. Error: EROFS: read-only file system, mkdir '/sys/fs/cgroup/cpu/safeify', 参考 #2376 修改了sandbox.js
  3. 现在返回errmsg: "解析出错,请检查。Error: Method Promise.prototype.then called on incompatible receiver [object Object]",
taunt123 commented 2 years ago

老哥问题解决了吗?

younglifestyle commented 2 years ago

同问

flyuuo9 commented 1 year ago

2022了,求问怎么解决的

jiewang-2023 commented 1 year ago

2023了,求问怎么写脚本

houchaowei commented 1 year ago

2023了,求问怎么写脚本

有处理方法了吗

lmovse commented 3 months ago

参考 #2675

TomPlack commented 2 months ago

2024了,求问怎么写脚本