Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

The "effects" system is not consistently used

Abierto
#1,920 0 comentarios 1 reacción 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
20/100
Tipo de issue
Refactorización
Claridad
Necesita aclaración
Estado de actividad
Estancado
Stack tecnológico
typescript
Área
tooling

Línea de trabajo

Start by reading the effects usage around src/deploy.ts lines 586-591 and compare it with the CI output example linked in the issue. Trace other direct file, stdout, and environment operations where an effects object is present. The issue does not define whether completion means removing effects or extending their use, so a concrete scope and done criteria are still needed.

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

Descripción

In a thread on another repo I said "[effects in Framework] aren't well understood or universally used". At @Fil's prompting, I wanted to expand on that.

In #39 we implemented the first version of the authentication process. It required reading and writing from files, remote APIs, and stdio. This made it hard to test without also dealing with a lot of state and making our test output very noisy. To try and make this easier to test, I drew on an idea from functional programming: algebraic effects.

JavaScript doesn't support algebraic effects, so I faked it by supplying various functions with an extra last parameter that provided a library of functions it could take. These were intended to be used for all "impure" behaviors: file operations, stdio, API calls, etc. By doing this, the test suite could provide an alternate version of the effects that didn't interact with the real resources, such as a having an in-memory file system or by feeding in an array of lines to "stdin". This helped make the tests quieter and easier to write, though it did make some code (the code in the effects) difficult or impossible to test.

Overtime, code was written that performed these "effectful" operations, but didn't use effects. For example, in the deploy process there is an effects object, but we directly read files to calculate their hashes. Reading files which should be an effect by the intent I explained above.

https://github.com/observablehq/framework/blob/82412a49f495a018367fc569f0407e06bae3479f/src/deploy.ts#L586-L591

Other parts of the code directly write to stdout, write to files, and perform other actions that interact with the environment without using effects, even when an effect object is in use in the same function. Here's an example in the CI output of output of the test being printed to stdout instead of being captured like the effect system says it should be.

From this I concluded that I did not properly embed the idea of effects into the code and explain it to the people working on Framework. That's ok.

I'm not arguing for or against effects in this issue. I wanted to explain the problem that I see. I think it would be reasonable to remove the effects system entirely. It would also be reasonable to work to extend effects to cover more of the code. I think the most prudent approach is probably to leave this as is, and keep this in mind in future code.

Lenguaje dominante
TypeScript
Estrellas
3.7k
Forks
209
Métricas de merge de PR
Sin PR fusionados en 30 d

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 observablehq/framework

Todos los issues de observablehq/framework

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.