我仍然可以在交易中续集V6上使用蓝鸟调用吗?

发布于 2025-02-13 03:56:03 字数 1580 浏览 0 评论 0原文

对于一个项目,我已经从续集V5迁移到> V6 如前所述在这里cls-hooked应该应该现在使用而不是连续本地存储。因此,我现在正在使用cls-hooked。另一个破裂的变化是,蓝鸟已被本地承诺所取代。 但是,我有很多代码包装续集调用(在交易的生命周期内)仍然使用蓝鸟,因为它具有许多方便的辅助方法,以至于本机承诺缺乏。

但是,现在有时(但并非一致)这样的奇怪错误,通过续集来提及: 错误,错误stackTrace:错误:已在此事务上调用COMIL(83E3C09B-EFD4-4A32-BC1E-2F009A20B9C0),您无法再使用它。 (被拒绝的查询作为此错误的“ SQL”属性附加)。从逻辑上讲,这对我来说没有意义,因为在交易提交之前应该已经完成​​了查询(并且在使用Continuation-continuation-Local-Storage时工作正常)。如果我对带有承诺的特定呼叫交换蓝鸟,我将无法再重现问题了。

当使用quelize v5时,我使用cls-bluebird来解决这些类似的问题,通过修补持续储存存储名称空间:

import * as cls from 'continuation-local-storage'
....
const clsBluebird = require('cls-bluebird');
clsBluebird(nameSpace);

但是,cls-bluebird是为continuation> continuation-local-local-nove < /code>(请参阅Cls-Bluebird的读数):

patch bluebird 持续本地存储支持。

在续集v6中可以修补一个像这样的cls钩的名称空间:

const cls = require('cls-hooked');
const nameSpace = cls.createNamespace("some-constant");
const clsBluebird = require('cls-bluebird');
clsBluebird(nameSpace);

有趣的是,解决了我的“提交已经称为...”问题,但是我怀疑让cls-bluebird修补不支持的cls-hooked库。有人可以验证吗?

如果没有,我想我唯一的选择是用本机承诺替换所有我的蓝鸟电话?

For a project I have migrated from sequelize v5 --> v6
As mentioned here, cls-hooked should now be used instead of continuation-local-storage. so I am now using cls-hooked. Another breaking change is that BlueBird has been replaced by native Promises.
However, I have a lot code that wraps the Sequelize calls (within the lifetime of the transaction) that still uses BlueBird, because it has so many convenient helper methods, that native Promises lack.

However, now sometimes (but not consistently) weird errors like this are mentioned by Sequelize:
Error, error stacktrace: Error: commit has been called on this transaction(83e3c09b-efd4-4a32-bc1e-2f009a20b9c0), you can no longer use it. (The rejected query is attached as the 'sql' property of this error). Logically this does not make sense to me, since the query should already have been done before the transaction is committed (and worked fine while using continuation-local-storage). If I for that specific call exchange BlueBird with Promise I cannot reproduce the problem anymore.

When using sequelize V5 I used cls-bluebird to solve these similar problems, by patching the continuation-local-storage namespace:

import * as cls from 'continuation-local-storage'
....
const clsBluebird = require('cls-bluebird');
clsBluebird(nameSpace);

However, cls-bluebird is especially made for continuation-local-storage (see the readme of cls-bluebird):

Patch bluebird for continuation-local-storage support.

It is possible in Sequelize V6 to patch a cls-hooked namespace like this:

const cls = require('cls-hooked');
const nameSpace = cls.createNamespace("some-constant");
const clsBluebird = require('cls-bluebird');
clsBluebird(nameSpace);

Interestingly, that fixes my " commit has been called... " problem, but I doubt if it is reliable to let cls-bluebird patch the unsupported cls-hooked library. Could someone verify that?

If not, I guess my only option is to replace all of my BlueBird calls with native Promises?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浪菊怪哟 2025-02-20 03:56:03

我发现 this 在Cls-Hooked Repo中发表的问题,作者在其中似乎表明Cls-Bluebird确实与Cls钩一起使用。

快速答案:是的,您将使用未插入的蓝鸟放松上下文。
看看“ Cls-Bluebird”
https://github.com/timbeyer/cls-bluebird

I found this issue in the cls-hooked repo, where the author seems to suggest that cls-bluebird does work with cls-hooked.

Quick answer: yes, you will loose context with an unpatched bluebird.
Take a look at 'cls-bluebird'
https://github.com/TimBeyer/cls-bluebird.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文