Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

Object.defineProperty TypeError: Attempting to configurable attribute of unconfigurable property #13895

Closed
MKuenzi opened this issue Jan 15, 2016 · 16 comments
Labels

Comments

@MKuenzi
Copy link

MKuenzi commented Jan 15, 2016

When I run this code in phantomjs:

var Test = (function()
{
        function Test()
        {
            this.instanceProp = "hello!";
        }

        Object.defineProperty(Test, "name", {
            get: function () {
                return "TextHelper";
            },
            enumerable: true,
            configurable: true
        });

        return Test;
})();

I am getting the error TypeError: Attempting to configurable attribute of unconfigurable property.

Running this code in Firefox, Chrome and IE does not seem to produce an issue.

Thanks in advance for your help.

@CyborgMaster
Copy link

I've run into the same issue. I'm running phonegap tests inside the ripple emulator inside phantomjs. During part of it's initialization it runs something like the following:

Object.defineProperty(window, 'name', {
  value: {}, configurable: true, enumerable: true
});

which throws this error:

TypeError: Attempting to configurable attribute of unconfigurable property.

This doesn't happen in Chrome. Interestingly enough I'm seeing the crash trying to define a property with the same name (name) as the OP. That might be a clue to the underlying issue.

@MKuenzi
Copy link
Author

MKuenzi commented Jan 26, 2016

Good observation. I have changed all uses of the property "name" in my code and everything seems to run fine now.

@CyborgMaster
Copy link

I wish I had that option. I'm using a third party tool (apache ripple emulator), and so I can't change the properties they use.

eriksjolund added a commit to eriksjolund/osd-spot-viewer that referenced this issue Aug 4, 2016
When trying out the web page in https://www.browserstack.com
by using their Iphone, I got an error

"TypeError: Attempting to change configurable attribute of unconfigurable property."
Searching Google for the error text led me to:
ariya/phantomjs#13895
Just speculating that name() could be causing the error so
I renamed it to filename(). There are two more name() functions
that have yet to be renamed.
eriksjolund added a commit to eriksjolund/osd-spot-viewer that referenced this issue Aug 4, 2016
by using their Iphone, I got an error

"TypeError: Attempting to change configurable attribute of unconfigurable property."
Searching Google for the error text led me to:
ariya/phantomjs#13895
Just speculating that name() could be causing the error so
I renamed it to parser_name(). There is one more name() function
that has yet to be renamed.
eriksjolund added a commit to eriksjolund/osd-spot-viewer that referenced this issue Aug 4, 2016
When trying out the web page in https://www.browserstack.com
by using their Iphone, I got an error

"TypeError: Attempting to change configurable attribute of unconfigurable property."
Searching Google for the error text led me to:
ariya/phantomjs#13895
Just speculating that name() could be causing the error so
I renamed it to layout_creator_name().
@CyborgMaster
Copy link

Just checking in on this issue. Has it been fixed?

@CyborgMaster
Copy link

I can confirm that this is still failing in phantomjs 2.1.1

@dfleury
Copy link

dfleury commented Jan 13, 2017

I had the same problem when testing my SPA which uses CasperJS+PhantomJS and InfernoJS.

@sridharrajagopal
Copy link

I have the same issue when using AWS SDK - aws-sdk-2.2.19.min.js

@sridharrajagopal
Copy link

Any updates on this?

Thanks,
Sridhar

@ljqx
Copy link

ljqx commented Jun 21, 2017

See Function.name, before ES6, Function.name is not configurable. I think for fixing this bug, PhantomJS needs to upgrade QtWebkit to latest version. Current QtWebkit 2.2 is released 2011, there will be more and more bugs like this one.

@ljqx
Copy link

ljqx commented Jun 21, 2017

There is already a tracing issue, see #14506. @ariya , this bug is related to ES6 too.

@AlexandreBonneau
Copy link

On my end I'm using:

Object.defineProperty(domElement, attributeToWatch, {
    set: val => {
        console.log('value has changed', val);
    },
});

where attributeToWatch can be 'value', 'textContent' or 'nodeValue' with PhantomJS 2.1.1, and I get that TypeError: Attempting to change access mechanism for an unconfigurable property. error message too.

@stale stale bot added the stale label Dec 26, 2019
@stale
Copy link

stale bot commented Dec 29, 2019

Due to our very limited maintenance capacity, we need to prioritize our development focus on other tasks. Therefore, this issue will be automatically closed (see #15395 for more details). In the future, if we see the need to attend to this issue again, then it will be reopened. Thank you for your contribution!

@stale stale bot closed this as completed Dec 29, 2019
@limingli0707
Copy link

limingli0707 commented May 12, 2020

Do you guys have any work around about this issue? I'm updating mt project with angular 1.7.9 and got the TypeError: Attempting to configurable attribute of unconfigurable property while running unit test, but it was working for with angular 1.7.5

@rksinghUI
Copy link

rksinghUI commented Jun 9, 2020

@limingli0707 , Have you got any fix for This issue. I am also trying to update to Angular 1.7.9 and stuck. Can you help with the solution.

@aleen42
Copy link

aleen42 commented Jan 24, 2022

Any progress?

@ilanb1996
Copy link

ilanb1996 commented Nov 14, 2022

I also have similar issue, im using phatomJs for running unit tests for legacy browsers (es5 support) and my tests keep failing, in the beginning ive used jasmine.spyOnProperty(document.body, 'scrollHeight', 'get') and got this error, then ive tried to use

Object.defineProperty(document.body, 'scrollHeight', {
          value: 1000,
          writable: true,
          configurable: true
        });

but i still get this error, not sure what to do, thinking on just dropping this test for phantomJs but i dont like it because its a hack and not a real solution

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

No branches or pull requests

10 participants