Your data. Anywhere you go.

New Relic for iOS or Android


Download on the App Store    Android App on Google play


New Relic Insights App for iOS


Download on the App Store


Learn more

Close icon

Cannot assign to read only property 'WEB' of object '#<WebFrameworkShim>'


#1

I have upgraded my service to use Node 8.16 from Node 6.11.5 . Also I updated the new relic agent from version 2.9.1 to version 5.9.1
I use node-cache (https://www.npmjs.com/package/node-cache) in the service to cache some Key Value pairs. But since the above two updates, I have started seeing the following error in the logs - Cannot assign to read only property 'WEB' of object '#<WebFrameworkShim>'

If I disable the new relic agent, the errors seems to go away. My only option is to disable new relic from the service now as I can’t see any other issues. Any ideas what could be going wrong here?


#2

Hello,

Will you be able to share what other logs entries show in your stack trace besides " Cannot assign to read only property ‘WEB’ of object ‘#’? This error must be pointing at some specific files.

Thanks!


#3

Weirdly enough the stack trace is from node-cache.

TypeError: Cannot assign to read only property 'WEB' of object '#<WebFrameworkShim>'
    at _clone (/opt/service/node_modules/clone/clone.js:156:16)
    at _clone (/opt/service/node_modules/clone/clone.js:156:18)
    at _clone (/opt/service/node_modules/clone/clone.js:156:18)
    at _clone (/opt/service/node_modules/clone/clone.js:156:18)
    at _clone (/opt/service/node_modules/clone/clone.js:156:18)
    at _clone (/opt/service/node_modules/clone/clone.js:156:18)
    at _clone (/opt/service/node_modules/clone/clone.js:156:18)
    at _clone (/opt/service/node_modules/clone/clone.js:156:18)
    at _clone (/opt/service/node_modules/clone/clone.js:156:18)
    at _clone (/opt/service/node_modules/clone/clone.js:156:18)
    at _clone (/opt/service/node_modules/clone/clone.js:156:18)
    at _clone (/opt/service/node_modules/clone/clone.js:156:18)
    at _clone (/opt/service/node_modules/clone/clone.js:156:18)
    at _clone (/opt/service/node_modules/clone/clone.js:156:18)
    at _clone (/opt/service/node_modules/clone/clone.js:156:18)
    at _clone (/opt/service/node_modules/clone/clone.js:156:18)
    at _clone (/opt/service/node_modules/clone/clone.js:156:18)
    at _clone (/opt/service/node_modules/clone/clone.js:156:18)
    at /opt/service/node_modules/clone/clone.js:136:26
    at Map.forEach (<anonymous>)
    at _clone (/opt/service/node_modules/clone/clone.js:134:14)
    at _clone (/opt/service/node_modules/clone/clone.js:156:18)
    at _clone (/opt/service/node_modules/clone/clone.js:156:18)
    at _clone (/opt/service/node_modules/clone/clone.js:156:18)
    at _clone (/opt/service/node_modules/clone/clone.js:156:18)
    at _clone (/opt/service/node_modules/clone/clone.js:156:18)
    at _clone (/opt/service/node_modules/clone/clone.js:156:18)
    at clone (/opt/service/node_modules/clone/clone.js:196:10)
    at NodeCache.module.exports.NodeCache._wrap (/opt/service/node_modules/node-cache/lib/node_cache.js:406:22)
    at NodeCache._wrap (/opt/service/node_modules/node-cache/lib/node_cache.js:12:59)
    at NodeCache.module.exports.NodeCache.set (/opt/service/node_modules/node-cache/lib/node_cache.js:179:29)
    at NodeCache.set (/opt/service/node_modules/node-cache/lib/node_cache.js:12:59)
    at CacheUtil.set (/opt/service/out/util/CacheUtil.js:39:20)
    at CacheUtil.<anonymous> (/opt/service/out/util/CacheUtil.js:34:18)
    at Generator.next (<anonymous>)
    at fulfilled (/opt/service/out/util/CacheUtil.js:4:58)
    at <anonymous>

This happens when trying to do a set to cache a value using node-cache.
I do not do any custom new relic stuff in the service. And my newrelic.js file looks like this:

use strict
exports.config = {
  logging: {
    level: 'info'
  },
  allow_all_headers: false,
  attributes: {
    enabled: [ ],
    include: [ ],
    exclude: [ ]
  },
  transaction_tracer: {
    enabled: true,
    transaction_threshold: 80
  }
}

#4

Hi @shuayhuaca do you have any updates on this?


#5

I am so sorry for the late response. I was out of the office.
Indeed is interesting that the stack trace only shows node-cache and it points out to this dependency: https://github.com/pvorb/clone. I was hoping to see something related to New Relic. Especially because you mentioned that when you disable New Relic, the error disappears.
Can you please double check one more time that if you remove New Relic you no longer get errors from clone and node-cache?
And can you also confirm that you don’t see New Relic anywhere in the stack trace?
By the way, your newrelic.js does look good to me and don’t worry, I don’t think this is connected to those clone errors.


#6

No worries @shuayhuaca
I confirm that the errors go away when New Relic is disabled. Also I have edited the previous response to show the entire stack trace. The only addition in the stack trace is the file called CacheUtil which is my custom class to set values using node-cache
My hunch is there is something going wrong with the way NewRelic does Instrumentation which conflicts with the node-cache lib.
I have disabled NewRelic for now and that has solved the problem, but I would prefer to not do that.

If it helps, CacheUtil looks like this:

import Cache from 'node-cache';

const fiveMinutes = 5 * 60;

export class CacheUtil {
  private readonly cache: Cache;

  constructor(private readonly cacheStandardTtl: number) {
    this.cache = new Cache({
      stdTTL: this.cacheStandardTtl || fiveMinutes
    });
  }

  private get(key: string): any {
    return this.cache.get(key);
  }

  async fromCache<T>(key: string, findFunc: () => Promise<T>): Promise<T> {
    const cachedResult = this.get(key);
    if (cachedResult) { return cachedResult; }

    const result = await findFunc();
    this.set(key, result);
    return result;
  }

  private set<T>(key: string, obj: T): void {
    this.cache.set(key, obj);
  }

}

#7

Hello again!

I tried to run a little experiment to test your hunch: “My hunch is there is something going wrong with the way NewRelic does Instrumentation which conflicts with the node-cache lib.”

I created a small/simple program that had both dependencies required (using a js file by the way, not a ts file like your CacheUtil) :
const newrelic = require(‘newrelic’);
const NodeCache = require(‘node-cache’);
const myCache = new NodeCache();

And I did not get any error stack traces or find any conflicts between those 2 dependencies. Things run smoothly.

I was using this module https://www.npmjs.com/package/node-cache. Were you using the same one or is this a typescript variation of that module?

Also, were you applying import newrelic from 'newrelic' in this CacheUtil file when things started failing? If the “import” or “require” New Relic part was on another file, please send me the code of that file instead, so I can see how you were integrating/requiring New Relic in your code.

If you can also send me the output of npm ls --parseable=true --depth=0, that’d be great!