question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

officially support mutating middleware

See original GitHub issue

Because of #65, specifically lodash.flatten, compose() returns a generator based on a copy of the provided array from that point in time. Any changes made to this array subsequently will no longer be reflected in the returned middleware.

Previously, one could mutate the array after calling compose.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:19 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
conorhastingscommented, Oct 26, 2016

@jonathanong The problem occurs if you call app.use to add any middleware after you’ve already triggered a call of app.callback, since this.middleware, the argument that is passed to compose is a mutable array.

this would previously work fine as it would reference the now mutated array, but since the flatten changes the semantics by copying at call time of compose with the flatten, anything added to the middleware after the call to compose is effectively ignored.

I would think that even if this wasn’t an envisioned use case, it still seems like a breaking change since it does, even if inadvertently, change the way the module works.

Thanks for all the hard work!

0reactions
jonathanongcommented, Aug 18, 2021

instead of supporting it here, we will add an ability to configure your compose function in koa https://github.com/koajs/koa/issues/1568

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mutation & Revalidation - SWR
Mutation & Revalidation. SWR provides the mutate and useSWRMutation APIs for mutating remote data and related cache.
Read more >
Modify res without mutating argument - Stack Overflow
Short answer? Yeah, the general rule is to mutate req and res as they go by your middleware. The official guide even suggests...
Read more >
Subscriptions - Apollo GraphQL Docs
You can use subscriptions with any of Apollo Server's supported middleware integrations. To do so, you call installSubscriptionHandlers on your ApolloServer ...
Read more >
Docs clarification: when are hooks called? · Issue #553 - GitHub
My use case is synchronising the state of some ents to an external service, obviously only if the mutation succeeds.
Read more >
Configuring Your Store - Redux
Most apps extend the functionality of their Redux store by adding middleware or store enhancers (note: middleware is common, enhancers are ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found