问题描述
我正在创造一种感觉,当您通过条形码时,条形码的产品将添加到表格中。
之后,我们有一个按钮将数据保存在表格中。对于每一行都需要生成一个标记,并插入到一个名为bo,bo2和bo3的表中。
使用bo的戳记,我们将插入到表中命名为bi,bi2和sl。
所以,我创建了一个struture来做这个承诺,但我有错误,但它只是发生在我有例如20行:
< node:6796> UnhandledPromiseRejectionWarning:未处理的承诺拒绝< reject id:13> ;: RequestError:Transaction< Process ID 61>被锁定的资源与另一个进程陷入僵局,并被选为死锁的受害者。重新运行交易。
使用mssql库完成与数据库的连接。
像我的功能更大,有必要显示所有的代码,让你更好地理解我将功能下面的链接的问题。
请阅读:
I'm creating a feauture that when you pass a bar code, the product of bar code is added to a table.
After that we have a button to save the data in table. For each row is necessary to generate a stamp and an insert into a table named bo, bo2 and bo3.
With the stamp of bo we will do an insert into a table named bi, bi2 and sl.
So, i created a struture to do this with promises but i have the error but it just happens when i have for example 20 rows:
<node:6796> UnhandledPromiseRejectionWarning: Unhandled promise rejection <rejection id: 13>: RequestError: Transaction <Process ID 61> was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.
The connection to database is done with mssql library.
Like my function is bigger and it is necessary to show all code to you understand better the problem i put the link below of my function.http://pastebin.com/MnM6AE6a
I already changed the structure of my function but the problem continue.
Thank you.
Your code example is 150 lines of code so I won't debug all of that (you should always provide a minimal code example needed to reproduce your problem and include in the question if you want people to help you spot and fix the actual errors) but the UnhandledPromiseRejectionWarning means that somewhere you didn't include a catch handler for a promise.
For example, if anywhere you have:
promise.then(func);
instead of:
promise.then(func1, func2);
or:
promise.then(func1).catch(func2);
Then your code is not halndling the promise rejections properly and as such is broken. In the future this program may not even start in next versions of Node - I explained it in more details in this answer:
Also, having looked at your code I strongly suggest reading about SQL injection attacks. I mean it. Google the subject and fix your code even before you fix the problem with unhandled promise rejections. Seriously. I'm not referring to this comic strip any more these years but every developer should know it and understand:
Please read:
- https://en.wikipedia.org/wiki/SQL_injection
- http://www.beyondsecurity.com/about-sql-injection.html
- http://projects.webappsec.org/w/page/13246963/SQL%20Injection
- http://bobby-tables.com/
这篇关于节点js - 承诺拒绝在处理大量数据时发生警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!