Code Monkey home page Code Monkey logo

Comments (7)

ekzyis avatar ekzyis commented on September 18, 2024

I think this is the cause:

2024-06-03-181343_1053x370_scrot

I encountered this error while working on #1184 but I thought it was part of my postpaid changes which weren't included in #1194

from stacker.news.

ekzyis avatar ekzyis commented on September 18, 2024

I can reliably reproduce the comment not showing up when I zap the parent first. But the cache warning does not show up. So maybe it's unrelated or another issue. I can't reproduce the cache warning.

from stacker.news.

huumn avatar huumn commented on September 18, 2024

If I uncomment the optimistic mutation code, it appears to fix it.

from stacker.news.

ekzyis avatar ekzyis commented on September 18, 2024

This also seems to fix it (at least for successful zaps):

diff --git a/components/item-act.js b/components/item-act.js
index 29babfd4..f4e360e1 100644
--- a/components/item-act.js
+++ b/components/item-act.js
@@ -277,7 +277,7 @@ export function useZap () {

       let hash, hmac;
       [{ hash, hmac }, cancel] = await payment.request(satsDelta)
-      await zap({ variables: { ...variables, hash, hmac } })
+      await zap({ variables: { ...variables, hash, hmac }, optimisticResponse, update })
     } catch (error) {
       revert?.()

diff --git a/lib/apollo.js b/lib/apollo.js
index d950ed68..17296bc1 100644
--- a/lib/apollo.js
+++ b/lib/apollo.js
@@ -259,7 +259,7 @@ function getClient (uri) {
 export function optimisticUpdate ({ mutation, variables, optimisticResponse, update }) {
   const { cache, queryManager } = getApolloClient()

-  const mutationId = String(queryManager.mutationIdCounter++)
+  const mutationId = String(queryManager.mutationIdCounter)
   queryManager.markMutationOptimistic(optimisticResponse, {
     mutationId,
     document: mutation,

But only removing ++ does not.

I added the ++ in a38dc10 for zap undos because iirc, not using ++ meant that the optimistic update for all zaps were undone when one zap was aborted.

Zap undos are lot less important than comments working properly but I'd like to find out if there's a way to get both working. I'd also like to find out what's actually happening instead of speculating why ++ breaks following mutations.

from stacker.news.

huumn avatar huumn commented on September 18, 2024

All mutations share the queryManager. So not incrementing it means all mutations would share that mutationId.

from stacker.news.

huumn avatar huumn commented on September 18, 2024

I'm sending you messages in chat. Have you figured that out yet?

from stacker.news.

ekzyis avatar ekzyis commented on September 18, 2024

Closing because fixed in #1220

from stacker.news.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.