processing / processing/p5.js-web-editor
Renamed `sketch.js` still executes when referenced in `index.html` (caching issue?)
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1.7k
- Forks
- 1.7k
- Avg merge
- 3d 4h
- Merged PRs (30d)
- 8
Description
p5.js version
2.1.1
What is your operating system?
Mac OS
Web browser and version
Chrome Version 142.0.7444.176 (Official Build) (arm64)
Actual Behavior
In the p5 web editor (p5.js 2.1.1) I am seeing cases where an old version of sketch.js keeps being executed or loaded even after the file has been renamed (for example to not.js).
In those cases:
- Changing
<script src="not.js">to<script src="sketch.js">makes the preview run an older version of the code, even thoughsketch.jsno longer exists in the Sketch Files panel. - This still happens when loading the same project in an incognito window, so it does not look like a simple browser cache issue.
Expected Behavior
- If
sketch.jshas been renamed or removed, referencing it inindex.htmlor vialoadStrings("sketch.js")should fail, not load a stale copy. - The preview should only execute and load files that exist in the Sketch Files panel.
Steps to reproduce
I have not yet found a reliable series of steps to reproduce from a fresh sketch, but the problem started in a sketch where await loadStrings("sketch.js") was used and the file was later renamed. I'm not sure whether that is significant.
Here is a sketch exhibiting that behavior: https://editor.p5js.org/SableRaf/sketches/wuZkibCGu
Try changing <script src="sketch.js"></script> to <script src="not.js"></script> and see the color change.
Additionally, when calling loadStrings("sketch.js") from not.js, the console output shows the old contents of sketch.js from before the file was renamed to not.js (see screenshot below). The file sketch.js no longer exists in the Sketch Files panel, yet loadStrings("sketch.js") still returns the previous version instead of failing.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked sketch and inspect the references to sketch.js and not.js in index.html, along with loadStrings("sketch.js") from not.js. Reproduce the stale-file behavior and trace how the preview resolves renamed files; done means removed or renamed files are no longer executed or returned, and missing references fail.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100