incubator-pagespeed-ngx icon indicating copy to clipboard operation
incubator-pagespeed-ngx copied to clipboard

InsertNodeBeforeNode: existing_node invalid

Open viktorix opened this issue 6 years ago • 5 comments

We have lazy loading enabled, and I noticed that images sometimes don't load at all. All images on pages. If I refresh once or twice, they show up. If I refresh again once or twice, they disappear. Scrolling doesn't help.

It does appear that lazy loading doesn't work correctly for some reason. I can see lazy loading attributes on hidden images. Our beacons are turned on. No console errors at all when images are hidden. Access logs show ngx_pagespeed_beacon requests are all 204.

The only relevant error I found in the nginx error log is this: [alert] 1409#0: [ngx_pagespeed 1.13.35.2-0] InsertNodeBeforeNode: existing_node invalid

This is a WordPress site. It's a LEMP stack, nothing fancy. CDN is also used with proper pagespeed mapping. We also use page caching, to serve HTML files.

What could cause issues with lazy loading?

Here's a screenshot of the hidden image: 2b793c2f-ccb4-4ec8-b947-c06039466eff

Tested in Chrome and Firefox.

viktorix avatar Mar 06 '19 04:03 viktorix

Can you reproduce that log message?

oschaaf avatar Mar 12 '19 22:03 oschaaf

Yes, nginx error log has many of these errors. I didn't notice this before, but these alerts correspond to errors of missing images. But, missing images error is not related to lazy loaded images.

2019/03/18 09:18:27 [alert] 1409#0: [ngx_pagespeed 1.13.35.2-0] InsertNodeBeforeNode: existing_node invalid
2019/03/18 09:18:27 [alert] 1409#0: [ngx_pagespeed 1.13.35.2-0] InsertNodeBeforeNode: existing_node invalid
2019/03/18 09:19:37 [error] 1409#0: *403684 open() "/wp-content/themes/rise-child/images/xit.gif" failed (2: No such file or directory), client: XXX.XXX.XXX.100, server: www.xxx.com, request: "GET /wp-content/themes/rise-child/images/xit.gif HTTP/1.1", host: "www.xxx.com", referrer: "https://www.xxx.com/blog/research-high-need-babies-fact-sheet/"
2019/03/18 09:19:37 [error] 1409#0: *403684 open() "/wp-content/themes/rise-child/images/icons/visa.png

What's interesting, the issue with lazy loading happens on one specific page as far as I can tell. Other pages and posts on this site work fine, lazy loading works as expected. Other pages similar in layout/features work fine. So I'm a bit puzzled as to what may be breaking lazy loading.

As I mentioned before, when I reload the page it might work, and then again reload and it won't work. What I noticed, when everything works there are 4 POST requests for ngx_pagespeed_beacon, but when lazy loading doesn't work there are only 2 requests.

viktorix avatar Mar 18 '19 15:03 viktorix

Just to add. Based on the referrer information for the error, it's not the page that's having lazy loading issue. So I'm not sure now if InsertNodeBeforeNode: existing_node invalid is even related to lazy loading issue.

The page that has lazy loading issue doesn't seem to be in nginx error logs at all. 😒

viktorix avatar Mar 18 '19 15:03 viktorix

I have not seen this in the wild before. The message comes from here:

https://github.com/apache/incubator-pagespeed-mod/blob/7659ff743638781f847e37500b8a7093fb49a2f8/pagespeed/kernel/html/html_parse.cc#L617

This should be a "this cannot happen" kind of scenario, but every once in a while those happen. Can you describe in more detail:

  • what filters are enabled
  • how you compiled ngx_pagespeed (did you compile for debug)
  • anything else interesting or unique about the environment in which ngx_pagespeed is running

jmarantz avatar Mar 18 '19 15:03 jmarantz

I believe I fixed this specific error: InsertNodeBeforeNode: existing_node invalid It appears that when a background image in CSS is missing, pagespeed will return this error. When I fixed path to images in the stylesheet, this error is no longer showing up in error log.

However, my original issue with lazy loading isn't related to this. I'm still stuck with one page not letting lazy loading to work properly.

viktorix avatar Mar 18 '19 15:03 viktorix