Skip to content

Detect if ses is being transformed #662

@kumavis

Description

@kumavis

it would be helpful for debugging if there were some heuristics for checking if the ses dists were being transformed, as in #659

even being woefully imperfect, this check can be useful by logging a warning or error suggesting that a transform might have taken place.

one common thing that is easy to check is if async functions are being transformed to non-async functions.

here is an example of the transformation.

original:

const testResult = Object.getPrototypeOf(async function AsyncFunctionInstance() {}) === Function.prototype
//=> normally false, but true after transformation

after transformation:

var testResult = Object.getPrototypeOf(function AsyncFunctionInstance() {
  return regeneratorRuntime.async(function AsyncFunctionInstance$(_context) {
    while (1) {
      switch (_context.prev = _context.next) {
        case 0:
        case "end":
          return _context.stop();
      }
    }
  }, null, null, null, Promise);
}) === Function.prototype;
//=> true

note that the transformed async function has a prototype of Function.prototype. we could throw an error suggesting that the code might have been transformed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    confinementPertaining to confinement of guest programs.kriskowal-review-2024-01Issues that kriskowal wants to bring to the attention of the team for review as of January, 2024

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions