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

fix: ip function error "[object Object]" #50

Merged
merged 2 commits into from
Jan 20, 2024
Merged

fix: ip function error "[object Object]" #50

merged 2 commits into from
Jan 20, 2024

Conversation

BLxcwg666
Copy link

Description

由于云函数 "ip" 中 hasCatchawait cache.get(ip);
属于一个对象,而下面直接对这个对象用了 JSON.parse,然后会报错
"message": "Function 执行报错: \"[object Object]\" is not valid JSON"
所以需要加一个判断,确保他是一个字符串,如果不是就转一下

Linked Issues

None

Additional context

None

由于云函数 "ip" 中 hasCatch 是 await cache.get(ip);
属于一个对象,而下面直接对这个对象用了 JSON.parse,然后会报错
"message": "Function 执行报错: \"[object Object]\" is not valid JSON"
所以需要加一个判断,确保他是一个字符串

Signed-off-by: BLxcwg666 <huixcwg@gmail.com>
@wibus-wee
Copy link
Member

hi @BLxcwg666. 我想知道这是在哪里出现的这个报错😂

@BLxcwg666
Copy link
Author

hi @BLxcwg666. 我想知道这是在哪里出现的这个报错😂

要是云函数里面配置了没修复的那个,你点开后台的评论管理里面,鼠标悬浮到ip上面,能查出来,你刷新一下,悬浮到同一个ip上面,就报错了,如果没复现需要我录视频复现一下吗 @wibus-wee

@BLxcwg666
Copy link
Author

hi @BLxcwg666. 我想知道这是在哪里出现的这个报错😂

或者你直接 curl https://后端域名/api/v2/fn/built-in/ip?ip=114.51.45.14
多 curl 两次就报错了

@wibus-wee
Copy link
Member

我这里无法复现这个问题😂 你能否提供一下出现报错问题时 hasCatch 的值?谢谢🙏

pages/docs/problems.mdx Outdated Show resolved Hide resolved
pages/docs/problems.mdx Outdated Show resolved Hide resolved
pages/docs/problems.mdx Outdated Show resolved Hide resolved
pages/docs/problems.mdx Outdated Show resolved Hide resolved
pages/docs/problems.mdx Outdated Show resolved Hide resolved
@BLxcwg666
Copy link
Author

BLxcwg666 commented Jan 20, 2024

我这里无法复现这个问题😂 你能否提供一下出现报错问题时 hasCatch 的值?谢谢🙏

你去仪表盘下拉清除一下 API 缓存 和 数据缓存,然后 curl 就能复现
image

至于两您说的问题是因为我是基于3天前默认的built-in的ip函数的基础上改的,可能对于现在来说有点出入

Copy link
Author

@BLxcwg666 BLxcwg666 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@wibus-wee
Copy link
Member

我看了一下 Core 的代码,好像...已经parse了啊😂

https://github.com/mx-space/core/blob/master/apps/core/src/modules/serverless/serverless.service.ts#L100-L108

@wibus-wee
Copy link
Member

不用了,我看到问题了哈哈哈 谢谢

Signed-off-by: BLxcwg666 <huixcwg@gmail.com>
@BLxcwg666
Copy link
Author

已经改了,如果没问题可以合一下 pr 吗

Copy link
Member

@wibus-wee wibus-wee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感谢🙏

@wibus-wee wibus-wee merged commit 9b696df into mx-space:docs/problems Jan 20, 2024
2 checks passed
@BLxcwg666 BLxcwg666 deleted the patch-2 branch January 20, 2024 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants