amphtml: Error: null is not an object (evaluating 'new a.Image')

Error: null is not an object (evaluating 'new a.Image')
at Image (https://raw.githubusercontent.com/ampproject/amphtml/1908121824440/src/window-interface.js:95)
at iframe (https://raw.githubusercontent.com/ampproject/amphtml/1908121824440/src/pixel.js:61)
at win (https://raw.githubusercontent.com/ampproject/amphtml/1908121824440/extensions/amp-analytics/0.1/transport.js:246)
at (https://raw.githubusercontent.com/ampproject/amphtml/1908121824440/extensions/amp-analytics/0.1/transport.js:132)
at requestUrl (https://raw.githubusercontent.com/ampproject/amphtml/1908121824440/extensions/amp-analytics/0.1/requests.js:260)

My guess is the window is destroyed by the time Transport.sendRequest is called. A null check may fix it.

/cc @ampproject/wg-analytics

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 18 (17 by maintainers)

Most upvoted comments

Ah so we pass in param by reference, makes sense. I’ll create a quick fix.

The reason why it’s hard to notice is probably b/c of the const Image = WindowInterface.getImage(win) in the:

const Image = WindowInterface.getImage(win);
const image = new Image();

It most likely gets inlined by the compiler, thus simply becoming:

const image = new win.Iimage();

My guess is the window is destroyed by the time Transport.sendRequest is called. A null check may fix it.

Have we tried doing this?