Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seemingly random "snapshots" when requiring a module that returns a table #215

Open
wqferr opened this issue Nov 11, 2023 · 9 comments
Open

Comments

@wqferr
Copy link

wqferr commented Nov 11, 2023

I'm trying to use Fengari on a personal project, but it sometimes just... stops updating my module return values? For instance, I'll add a new function to the table, and then Fengari just decides it doesn't exist. Every other field previous to that is fine, but the new one disappears.

I've tried restarting my web server to no avail, I'm kind of lost at this point. I want to use Fengari but this is making it really difficult for me.

@wqferr
Copy link
Author

wqferr commented Nov 11, 2023

The only solution I see presently is to port my entire application over to JS and use Fengari exclusively to load my libraries... Which I'd rather not do.

@wqferr
Copy link
Author

wqferr commented Nov 11, 2023

OK so progress on the problem: it seems my editor wasn't updating the file's last edited timestamp, not sure why that would ever happen, but once I touched the file, it instantly updated. This will serve as a workaround for now.

Not sure there's anything you can (or should) do with this issue, this is very clearly a problem with my setup. I'll leave the issue open to let you know what happened and see what you do (if you do) anything about it.

@wqferr
Copy link
Author

wqferr commented Nov 11, 2023

NOPE never mind, touching the file doesn't always work. I'm lost guys, please help.

@wqferr
Copy link
Author

wqferr commented Nov 11, 2023

Further testing seems to show that it only ever happens in Firefox, but I need to investigate more

@wqferr
Copy link
Author

wqferr commented Nov 11, 2023

Testing concluded this still happens on chrome. No idea what causes it. It's not caching (at least not in any form I can disable).

@daurnimator
Copy link
Member

Are you just running into the fact that require caches the loaded module?

@wqferr
Copy link
Author

wqferr commented Nov 12, 2023

Wouldn't touching the file invalidate the cache? Also how does it cache the module between server restarts? Do you save the module elsewhere on the disk?

Also if that were the case, I wouldn't simultaneously have a different problem: when multiple files require the same module, they get different copies. I know this because one of my modules does a metatable comparison, and in one file it was passing while not in the other.

Is there a way to disable these functions? They are getting in the way more than helping.

Thank you for the quick reply though.

@daurnimator
Copy link
Member

daurnimator commented Nov 12, 2023

require in fengari caches until the page is reloaded. It's not related to the server side

https://www.lua.org/manual/5.4/manual.html#pdf-require

@wqferr
Copy link
Author

wqferr commented Nov 13, 2023

Then the behavior I encountered wasn't caching, because it kept happening even when force reloading the page with no cache.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants