pywb icon indicating copy to clipboard operation
pywb copied to clipboard

Module Scripts run in strict mode - Wombat has uninititated variable so script doesn't run

Open mhiggins285 opened this issue 3 years ago • 6 comments
trafficstars

Describe the bug

Working with several pages that have script tags with the type="module" attribute. This causes them to run in strict mode, which does not allow variables to declared without initiating them. As Wombat contains the uninitialised variable 'arguments', this throws an error and the script isn't executed. I have tried to get around this by readding the scripts back in without type="module" but this has led to mixed results.

Steps to reproduce the bug

Load up an archived page in PYWB with a script tag that has 'type="module"'. Look in the console to see the error thrown due to the uninitiated variable. See examplar console log below.

Expected behavior

Script should run without error being thrown.

Screenshots

image

Environment

  • OS: iOS 12.5.1
  • Browser: Chrome 107.0.5304.87

mhiggins285 avatar Nov 10 '22 12:11 mhiggins285

We have a modified rewriting approach for JS modules, its supported in replayweb.page / wabac.js, but not yet in pywb. We have issue #764 to track that work. Once that's fixed/merged in, I think that should address the issue you're having

ikreymer avatar Nov 17 '22 21:11 ikreymer

@mhiggins285 can you try this branch: https://github.com/webrecorder/pywb/tree/dev/issue-674-module-rewriting to see if it fixes the issue? If not, and you have an example URL or WARCs to share, that would be helpful as well.

ikreymer avatar Nov 18 '22 16:11 ikreymer

@ikreymer Hi Ilya, I've tried to use that branch and I'm still getting the same issue

I've attached the WARC I used if that's helpful

MW-belpointasset-b453fd3f-567a-46c2-9cea-6c3156e3a0e8-000-20221206070319-ckwmg.com-00000.warc.gz

mhiggins285 avatar Dec 08 '22 14:12 mhiggins285

@mhiggins285 I couldn't find a page that has

ikreymer avatar Dec 10 '22 01:12 ikreymer

Apologies Ilya: I manually added type="module" into a script tag in that WARC to test, which might be why you had issues finding it, and I re-gziped it myself after it had already been compressed which might explain why it was compressed incorrectly

Here is the like to the warc (as originally compressed), I originally noticed the issue with: https://drive.google.com/file/d/1JAxoIrTdFScBR5JqwJZ9CWLLcJFXFRcR/view?usp=sharing

Let me know if you need anything else - thanks

mhiggins285 avatar Dec 12 '22 10:12 mhiggins285

This is currently still an issue - in strict mode (including all modules), you can't create a variable named "arguments", which pywb appears to be doing here.

  • Chrome throws this error: Uncaught SyntaxError: Unexpected eval or arguments in strict mode
  • Firefox throws this error: Uncaught SyntaxError: 'arguments' can't be defined or assigned to in strict mode code

rameshvarun avatar Aug 31 '23 09:08 rameshvarun