微风错误:非法施工 - 使用'或'结合检查 [英] Breeze error: Illegal construction - use 'or' to combine checks

查看:74
本文介绍了微风错误:非法施工 - 使用'或'结合检查的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了这个Breeze错误

I met this Breeze error


[非法施工 - 使用'或'结合支票]

[Illegal construction - use 'or' to combine checks]

。刷新页面时,不再显示错误消息。此错误在我的网站上随机,不定期地发生。我无法使用指定的场景重现它,只是随机遇到它。

on Chrome when loading the edit page of an entity. When I refresh the page, the error message no longer appears. This error happens randomly, irregularly on my site. I could not reproduce it using a specified scenario, just met it by random.

我在Breeze代码中看到此错误消息

I see this error message inside Breeze code

if (curContext.prevContext === null) {
    curContext.prevContext = context;
    // just update the prevContext but don't change the curContext.
    return that;
} else if (context.prevContext === null) {
    context.prevContext = that._context;
} else {
    throw new Error("Illegal construction - use 'or' to combine checks");
}

请您告诉我:根据以上代码块,在哪些情况下抛出这个错误?

Could you please tell me: based on above block of code, in which cases this error is thrown?

非常感谢。

推荐答案

我们有点难过,因为当发生这种情况时,没有人可以确定。

We're kind of stumped because no one can pin down when this happens.

你们都帮我们一个忙,修改你的breeze.debug.js以获取更多关于投掷时的状况?

Would you all do us a favor and modify your breeze.debug.js to capture more information about the state of affairs when it throws?

也许你可以添加这个:

} else {
     console.log("** Aaargh! 'curContext.prevContext': " + curContext.prevContext +
                " 'context.prevContext': " + context.prevContext);
     throw new Error("Illegal construction - use 'or' to combine checks");
}

抓住稻草。所有信息都有帮助。

Grasping at straws. All info helps.

AHA!谢谢@steve,@ matthias和其他人!

AHA! Thank you @steve, @matthias, and others!

正如我私下怀疑的那样,在某个地方,有人决定将prevContext设置为未声明

而不是 null 。我打算建议我们切换到==无论如何......这将处理两种情况。 FOSiness足够好IMO。当我们这样做时我们会回复你(假设Breeze团队中没有人反对应用我们无法测试的修复)。

As I privately suspected, something, somewhere, has decide to set prevContext to undeclared instead of null. I was going to recommend that we switch to "==" anyway ... which would handle both cases. Falsiness is good enough IMO. We'll get back to you when we do it (assuming no one inside the Breeze team objects to applying a fix that we can't test).

我在Chrome v33中使用 breeze.min.js 运行我的DocCode测试,它们都通过了。令人沮丧。 Jay将在Chrome v33中使用 breeze.min.js 运行他的测试...我们将看到他们中的任何一个是否失败。我没有希望。

I'm running my DocCode tests with breeze.min.js in Chrome v33 and they all pass. Frustrating. Jay will run his tests with breeze.min.js in Chrome v33 too ... and we will see if any of them fail for him. I am not hopeful.

我得到了 parm 的明智(包括非法)变体的预期行为( undefined null true false 字符串)来自 getEntityType 的行@Matthias提到

I get the expected behavior for sensible (including illegal) variations of parm (undefined, null, true, false, a string) on the line from getEntityType that @Matthias mentioned

assertParam(parm, "okIfNotFound").isBoolean().isOptional().check(false);

我对代码的静态分析(谁信任 ?)告诉我第一个比较运算符必须保持 === ,而第二个子句中的比较运算符可以是 == === 。代码作者努力确保左操作数在实践中从不 undefined ;我的静态分析显示它可能变成 未定义 ...虽然我无法安排世界以便它发生。也许是想象力的失败。

My static analysis of the code (who trusts that?) tells me that the first comparison operator must remain === whereas the comparison operator in the second clause can be either == or ===. The code author worked hard to make sure that the left operand was never undefined in practice; my static analysis shows that it could become undefined ... although I am unable to arrange the world so that it happens. Maybe a failure of imagination.

我对缩小代码的静态分析表明它是正确的,尽管 我的 缩小版本与你的不同,也许是因为我的缩小了breeze.debug.js的演变副本(更接近于v.1.4.9)。

My static analysis of the minified code says it is correct although my minified version is different from yours, perhaps because mine is minified against an evolving copy of breeze.debug.js (somewhere closer to what v.1.4.9 will be).

// Reformatted w/ spaces and new lines for readability. 
// Observe that the minifier reversed the direction of the second null test!
// That is smart and does no harm
// I can assure you the pre-minified code is the same as what you folks are reporting.
function m(a,b) {
    if(a._context){
          for(var c=a._context; null!=c.prevContext;) c=c.prevContext;
          if(null === c.prevContext) return c.prevContext=b, a;
          if(null !== b.prevContext)
               throw new Error("Illegal construction - use 'or' to combine checks");
          b.prevContext=a._context
    }
    return n(a,b)
}

在这些艰难的情况下,除非我们能找到失败的测试,否则我们将实现信仰的飞跃,屠宰鸡只,拨打一些骨头,并将代码更改为:

Under these trying circumstances, unless we can find a failing test, we'll make a leap of faith, slaughter a chicken, rattle some bones, and change the code to this:

if (curContext.prevContext === null) {
    curContext.prevContext = context;
    // just update the prevContext but don't change the curContext.
    return that;
} else if (context.prevContext == null) {  // CHANGED TO "if null or undefined"
    context.prevContext = that._context;
} else {
    throw new Error("Illegal construction - use 'or' to combine checks");
}

如果您可以抽出时间,请在您的应用中尝试此操作并确认一切都很好。

If you can make the time, please try this in your apps and confirm that all is well.

我们明天(2月28日)发货v.1.4.9所以请试试这个!

We're shipping v.1.4.9 tomorrow (28 Feb) so please try this pronto!

这篇关于微风错误:非法施工 - 使用'或'结合检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆