X Tutup
Skip to content

Including code from facade/lang.ts twice leads to RangeError: Maximum call stack size exceeded errors #4981

@pkozlowski-opensource

Description

@pkozlowski-opensource

While working on CJS bundles we've decided to duplicate facades code in each and every bundle. This means that if multiple bundles are loaded on the same page (say, core and http) we are executing code contained in facades twice. But it turns out that we've got a piece of code in facade/lang.ts that leads to
RangeError: Maximum call stack size exceeded errors. The culprit is here:

var assertionsEnabled_ = typeof _global['assert'] !== 'undefined';
export function assertionsEnabled(): boolean {
  return assertionsEnabled_;
}

// TODO: remove calls to assert in production environment
// Note: Can't just export this and import in in other files
// as `assert` is a reserved keyword in Dart
_global.assert = function assert(condition) {
  if (assertionsEnabled_) {
    _global['assert'].call(condition);
  }
};

This blocks #4278

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup