Renamed `sketch.js` still executes when referenced in `index.html` (caching issue?)

Abierto
#3,736 8 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 4 días

@SinhaS12 ya está trabajando en esto.

Desde el 2/12/2025.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
30/100
Tipo de issue
Error
Claridad
Necesita aclaración
Estado de actividad
Estancado
Stack tecnológico
javascript
Área
web-dev

Línea de trabajo

Empieza con el sketch enlazado e inspecciona las referencias a sketch.js y not.js en index.html, junto con loadStrings("sketch.js") de not.js. Reproduce el comportamiento de los archivos obsoletos y sigue cómo la vista previa resuelve los archivos renombrados; la tarea está terminada cuando los archivos eliminados o renombrados ya no se ejecuten ni se devuelvan, y las referencias faltantes fallen.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Bug Needs Discussion
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 though sketch.js no 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.
Image Image
Expected Behavior
  • If sketch.js has been renamed or removed, referencing it in index.html or via loadStrings("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.

Image
Lenguaje dominante
JavaScript
Estrellas
1.7k
Forks
1.7k
Merge medio
7 d 1 h
PR fusionados (30 d)
13

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de processing/p5.js-web-editor

Todos los issues de processing/p5.js-web-editor

Issues similares

Más issues de JavaScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.