Comments (7)
求升级npm - - !
from thinkjs.
此问题还是存在.
Node版本:5.0.0
用于rest controller中
export default class extends think.controller.rest {
/**
* init
* @param {Object} http []
* @return {} []
*/
init(http) {
super.init(http);
}
/**
* before magic method
* @return {Promise} []
*/
__before() {
}
async getAction() {
let User = this.model('user');
let query = this.http.query;
try {
let is = await User.checkExist(query.username);
if (is) {
this.success({msg: 'have'});
} else {
let id = await User.add(query);
console.log(id)
this.success({id: id});
}
} catch (e) {
this.fail(e.message);
}
}
}
测试了多次,当model里面有add,delete等模型操作会引起 循环引用。
from thinkjs.
能把详细的错误信息提供下么?
from thinkjs.
可以的。
复现也特别容易就是在model里面 定义方法的时候 使用add等关键字字段
user model代码:
// XXX: 模型操作add关键字会引起循环引用
add(query) {
return this.add({
username: query.username,
password: think.md5(query.password),
status: STATUS.ACTIVATED,
timestamp: new Date().getTime()
})
}
引用代码就是上面的代码
export default class extends think.controller.rest {
/**
* init
* @param {Object} http []
* @return {} []
*/
init(http) {
super.init(http);
}
/**
* before magic method
* @return {Promise} []
*/
__before() {
}
async getAction() {
let User = this.model('user');
let query = this.http.query;
try {
let is = await User.checkExist(query.username);
if (is) {
this.success({msg: 'have'});
} else {
let id = await User.add(query);
console.log(id)
this.success({id: id});
}
} catch (e) {
this.fail(e.message);
}
}
}
报错消息:
{"errno":1000,"errmsg":"Maximum call stack size exceeded"}
避免发生:
把add等关键字改成非关键字即可。
from thinkjs.
你定义的方法名是 add
,里面又调用了 add
方法,这样肯定会死循环啊。
from thinkjs.
定义的方法名不要和框架提供的方法名相同,不然的话会冲掉框架提供的方法。
from thinkjs.
可不可以在命令行 提供模型方法的列表 或者 必要的说明 或 log信息 。
因为常见的命名很容易冲突, 排查起来比较困难。
from thinkjs.
Related Issues (20)
- 自己封装的一个netSocket,无法正常获取websocket通道
- 请问多进程之间的数据如何共享?
- distinct貌似有bug HOT 1
- 有个接口文档中忘记写了。
- 大佬,你好,看到了你的部署thinkjs到vercel的文章了,这个vercel怎么和mysql连接起来,有推荐的文章吗?谢谢 HOT 1
- 无法在Object原型上添加方法 HOT 3
- 如何禁用 ESLINT 检测功能 HOT 2
- Ubuntu server 22.04.01 执行安装 npm install -g think-cli 后 提示 [email protected]: Please upgrade to version 7 or higher. HOT 8
- 官网打不开了,更新一下ssl HOT 1
- 找不到名称“think”。找不到命名空间“think”。 HOT 2
- 找不到命名空间“think”。
- thinkjs 2.2 websocket无法连接成功
- 请问ThinkJS 底层依赖的库有必要升级吗? HOT 9
- think-logger 最新的1.3.1版本只能保存今天和昨天的日志两个文件 HOT 6
- 怎么设置请求超时时间? HOT 4
- 使用教程里的Dockerfile部署后访问接口404 Not found的问题 HOT 1
- 希望能在请求里输出请求id HOT 2
- [think-model-sqlite] Default values surrounded by single quotes HOT 3
- 彻底凉了!!!
- 上传大文件超时问题如何解决? || How to solve the timeout problem of uploading large files? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from thinkjs.