Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running object.assign under SES #82

Closed
katelynsills opened this issue Feb 10, 2021 · 4 comments
Closed

Running object.assign under SES #82

katelynsills opened this issue Feb 10, 2021 · 4 comments

Comments

@katelynsills
Copy link

Hi @ljharb, I'm trying to use Enzyme under SES, and I'm running into an issue that involves the object.assign package and define-properties package, although it may be solved by something lower down in the dependency tree.

Here's what I'm seeing:

TypeError: Cannot define property getPolyfill, object is not extensible
    at defineProperty (<anonymous>)
    at defineProperty (/Users/katesills/code/agoric-sdk/node_modules/define-properties/index.js:34:3)
    at defineProperties (/Users/katesills/code/agoric-sdk/node_modules/define-properties/index.js:52:3)
    at Object.<anonymous> (/Users/katesills/code/agoric-sdk/node_modules/object.assign/index.js:11:1)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
    at Object.<anonymous> (/Users/katesills/code/agoric-sdk/node_modules/enzyme/build/ReactWrapper.js:11:15)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
    at Object.<anonymous> (/Users/katesills/code/agoric-sdk/node_modules/enzyme/build/index.js:3:21)
    at Generator.next (<anonymous>)
    at Object.<anonymous> (/Users/katesills/code/agoric-sdk/packages/ui-components/compiled/test/_setup-enzyme-adapter.js:1)
    at Generator.next (<anonymous>)
    at load (/Users/katesills/code/agoric-sdk/packages/ui-components/node_modules/ava/lib/worker/subprocess.js:213:10)
    at /Users/katesills/code/agoric-sdk/packages/ui-components/node_modules/ava/lib/worker/subprocess.js:218:22
    at processTicksAndRejections (internal/process/task_queues.js:97:5)

  › TypeError: Cannot define property getPolyfill, object is not extensible
  › defineProperty (<anonymous>)
  › defineProperty (/Users/katesills/code/agoric-sdk/node_modules/define-properties/index.js:34:3)
  › defineProperties (/Users/katesills/code/agoric-sdk/node_modules/define-properties/index.js:52:3)
  › Object.<anonymous> (/Users/katesills/code/agoric-sdk/node_modules/object.assign/index.js:11:1)
  › Object.<anonymous> (/Users/katesills/code/agoric-sdk/node_modules/enzyme/build/ReactWrapper.js:11:15)
  › Object.<anonymous> (/Users/katesills/code/agoric-sdk/node_modules/enzyme/build/index.js:3:21)
  › Generator.next (<anonymous>)
  › Object.<anonymous> (compiled/test/_setup-enzyme-adapter.js:1)
  › Generator.next (<anonymous>)

It seems like the most obvious solution is to change define-property to return early if the object is frozen, but I'm not sure this is the right approach.

var defineProperty = function (object, name, value, predicate) {
	if (Object.isFrozen(object)) {
		return;
	}
	if (name in object && (!isFunction(predicate) || !predicate())) {
		return;
	}
	...

Thanks!

@ljharb
Copy link
Owner

ljharb commented Feb 10, 2021

hmm - how could the object be frozen? it's a function created inside that file (not the one that gets shimmed to Object, either). What version of object.assign do you have installed?

@katelynsills
Copy link
Author

Enzyme seems to be using define-properties v1.1.3 and object.assign v4.1.0.

Object.assign is frozen by SES before this code runs. If I change the define-properties code to include a console.log, I get the following:

var defineProperty = function (object, name, value, predicate) {
	console.log('is object frozen', Object.isFrozen(object), object);
is object frozen true [Function: assign] Function <Function <[Object: null prototype] {}>>
is object frozen true [Function: assign] Function <Function <[Object: null prototype] {}>>
is object frozen true [Function: assign] Function <Function <[Object: null prototype] {}>>
is object frozen true [Function: assign] Function <Function <[Object: null prototype] {}>>
is object frozen true [Function: assign] Function <Function <[Object: null prototype] {}>>
is object frozen true [Function: assign] Function <Function <[Object: null prototype] {}>>

@ljharb
Copy link
Owner

ljharb commented Feb 10, 2021

Ah, that bug was fixed in fc41c80, which is available in v4.1.1 and higher :-) feel free to update!

@ljharb ljharb closed this as completed Feb 10, 2021
@katelynsills
Copy link
Author

Ah, that bug was fixed in fc41c80, which is available in v4.1.1 and higher :-) feel free to update!

Great! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants