dmorlock
(Daniel Morlock)
4 Mayo, 2022 15:27
1
Nos encontramos con un error en el que parece faltar el tema-javascripts:
$ curl https://mydomain.com | grep "theme-javascript"
<script src="/theme-javascripts/ff7f780a40bfd1e31a2cdc99c7dbc616f619d7d9.js?__ws=mydomain.com"></script>
<script src="/theme-javascripts/1bb8395b8d8d9daecdbef830d8c9418b93a7b5f9.js?__ws=mydomain.com"></script>
Pero cuando intentamos acceder a estos archivos (en un navegador con un usuario conectado) obtenemos un error 404:
¡Hoppla! Esta página no existe o es privada.
Cuando revisamos la javascript-cache, los archivos existen:
$ find /var/www/discourse/tmp/javascript-cache -iname 'ff7f780a40bfd1e31a2cdc99c7dbc616f619d7d9*'
/var/www/discourse/tmp/javascript-cache/ff7f780a40bfd1e31a2cdc99c7dbc616f619d7d9.js
La solución provisional actual es editar el tema personalizado cambiando y guardando el tema.
Después de 1-2 días, el problema vuelve a ocurrir.
Agradeceríamos cualquier ayuda para investigar más a fondo.
Gracias,
Daniel.
david
(David Taylor)
4 Mayo, 2022 17:10
2
¿Qué versión de Discourse estás ejecutando? Solucionamos un problema similar en febrero:
committed 01:23PM - 14 Feb 22 UTC
There is a couple of layers of caching for theme JavaScript in Discourse:
The… first layer is the `javascript_caches` table in the database. When a theme
with JavaScript files is installed, Discourse stores each one of the JavaScript
files in the `theme_fields` table, and then concatenates the files, compiles
them, computes a SHA1 digest of the compiled JavaScript and store the results
along with the SHA1 digest in the `javascript_caches` table.
Now when a request comes in, we need to render `<script>` tags for the
activated theme(s) of the site. To do this, we retrieve the `javascript_caches`
records of the activated themes and generate a `<script>` tag for each record.
The `src` attribute of these tags is a path to the `/theme-javascripts/:digest`
route which simply responds with the compiled JavaScript that has the requested
digest.
The second layer is a distributed cache whose purpose is to make rendering
`<script>` a lot more efficient. Without this cache, we'd have to query the
`javascript_caches` table to retrieve the SHA1 digests for every single
request. So we use this cache to store the `<script>` tags themselves so that
we only have to retrieve the `javascript_caches` records of the activated
themes for the first request and future requests simply get the cached
`<script>` tags.
What this commit does it ensures that the SHA1 digest in the
`javascript_caches` table stay the same across compilations by adding an order
by id clause to the query that loads the `theme_fields` records. Currently, we
specify no order when retrieving the `theme_fields` records so the order in
which they're retrieved can change across compilations and therefore cause the
SHA1 to change even though the individual records have not changed at all.
An inconsistent SHA1 digest across compilations can cause the database cache
and the distributed cache to have different digests and that causes the
JavaScript to fail to load (and if the theme heavily customizes the site, it
gives the impression that the site is broken) until the cache is cleared.
This can happen in busy sites when 2 concurrent requests recompile the
JavaScript files of a theme at the same time (this can happen when deploying a
new Discourse version) and request A updates the database cache after request B
did, and request B updates the distributed cache after request A did.
Internal ticket: t60783.
Co-authored-by: David Taylor <david@taylorhq.com>
3 Me gusta
dmorlock
(Daniel Morlock)
5 Mayo, 2022 19:32
3
Estamos usando la V2.8.0. ¿Qué versión contiene la corrección mencionada?
david
(David Taylor)
6 Mayo, 2022 09:51
4
Esta corrección solo está en la versión 2.9.0 (beta). Veré si podemos incluirla en la versión estable, ya que es una corrección relativamente simple: (PR aquí )
Edición: eso se ha fusionado en la rama estable @dmorlock . Así que si realizas una actualización (a través de la consola o de /admin/upgrade), el problema debería estar resuelto.
3 Me gusta
dmorlock
(Daniel Morlock)
6 Mayo, 2022 21:38
5
Acabamos de actualizar a la rama estable y actualmente estamos probando si esto solucionó nuestro problema.
1 me gusta
david
(David Taylor)
Cerrado
5 Junio, 2022 21:38
6
Este tema se cerró automáticamente 30 días después de la última respuesta. Ya no se permiten nuevas respuestas.