Internal Javascript Error

I have a TW (5.2.5) which has worked flawlessly for some time but has now started throwing a Javascript error on starting.
I’m on Windows 11 with node.js for TW.

Internal JavaScript Error

Well, this is embarrassing. It is recommended that you restart TiddlyWiki by refreshing your browser

sorry there was something wrong when trying to map your filter.
error : TypeError: Cannot read properties of undefined (reading ‘match’)

How do I debug and fix this?

Thanks

Depends, if you have plugins you can disable all of them and re-enable them one by one.

I use MS Edge and Chrome, which allow you to open a developer’s window/Dev Tools. Press F12 to open it. In the upper right, there should be a few icons, one with a red X and a counter, representing the number of errors. I suspect you’ll have a count of 1. Click on it. It should open to the line of code where the error occurred. This will likely tell us which plug-in is raising the error.

However, having said this, based on your error it would suggest the error was raised in Leaflet, specifically in $:/plugins/sycom/leaflet/mapWidget.tid

If this is correct, you likely have a filter being used in the plugin that causes this issue. I guess it could be a specific tiddler found in a filter you supplied to leaflet. You need to find and review that filter.

Hope this helps,

Craig

Craig, that’s really helpful. I am using Leaflet so you have given a good number of clues to follow up. Thanks.

What tileLayer are you using? Default is osm. If you are using osm, does changing it to something else change the behaviour?

I am relying on having points defined in the tiddler fields. I switched the map to ‘sat’ in the mapWdget.tid. However, it still failed.

Trying this multiple times and I spotted that the tiddlers that threw the javascript error were those that had an empty text area. Once the error appeared, despite closing the error dialog ANY tiddler (even if it had text) would then give the javascript error again.

So I closed the session in the command window and edited a few empty tiddlers putting in some dummy text.
I discovered two scenarios:

  1. If it was a line of text ending with a ‘LF’, it would fail and actually delete all the text if I tried to open the tiddler in TW.
  2. If it was some text with no ‘LF’ all seemed OK.

There is presumaly some logic in the Leaflet plugin that displays the map AFTER the text area in the displayed tiddler, so I am guessing it is very particular as to what it recognises as the end of the text area.

Hello, I had a similar problem with leaflet, maybe this will help? [Solved] Leaflet plugin on node.js error

1 Like

Thanks, that’s exactly the problem.
if (flds.text !== "")
So it seems it’s the Leaflet plugin that still needs updating.