-
Notifications
You must be signed in to change notification settings - Fork 24
Revert "fix: manually surface LIP-118 poll while subgraph indexing is behind" #753
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,7 +28,6 @@ import { | |
| useVoteQuery, | ||
| } from "apollo"; | ||
| import { sentenceCase } from "change-case"; | ||
| import { getManualPoll, isManualPoll } from "constants/manualPolls"; | ||
| import Head from "next/head"; | ||
| import { useRouter } from "next/router"; | ||
| import { useEffect, useState } from "react"; | ||
|
|
@@ -91,22 +90,18 @@ const Poll = () => { | |
|
|
||
| useEffect(() => { | ||
| const init = async () => { | ||
| // Fall back to a manually-listed poll when the subgraph doesn't have it | ||
| // (e.g. created while indexing was down), so it stays viewable/votable. | ||
| const source = data?.poll ?? getManualPoll(pollId); | ||
| if (source && currentRound?.currentL1Block) { | ||
| if (data && currentRound?.currentL1Block) { | ||
| const response = await getPollExtended( | ||
| source, | ||
| data.poll, | ||
| currentRound.currentL1Block | ||
| ); | ||
| setPollData(response); | ||
|
Comment on lines
+93
to
98
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== candidate files =="
fd -a 'poll.*\.(ts|tsx)$|voting.*\.(ts|tsx)$' . | sed 's#^\./##' | head -100
echo "== target file outline/size =="
wc -l pages/voting/[poll].tsx 2>/dev/null || true
ast-grep outline "pages/voting/[poll].tsx" 2>/dev/null || true
echo "== relevant lines =="
cat -n "pages/voting/[poll].tsx" | sed -n '1,180p'
echo "== getPollExtended usages/definition =="
rg -n "function getPollExtended|const getPollExtended|getPollExtended\(" . -SRepository: livepeer/explorer Length of output: 7063 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Locate source without relying on exact path
echo "== git ls files matching poll_extended or polling =="
git ls-files | rg -i 'poll|extended' | head -120
echo "== search api call helpers =="
rg -n "getPollExtended|poll_extended|extended" . -S | head -200Repository: livepeer/explorer Length of output: 1755 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== lib/api/polls.ts =="
cat -n lib/api/polls.ts | sed -n '1,180p'
echo "== apollo schema/types around poll =="
cat -n apollo/createSchema.ts | sed -n '1,180p'
rg -n -C 4 "poll|Poll|id: ID|status: PollStatus|currentL1Block" apollo queries lib/api pages/voting -S | head -260
echo "== all uses of pollData attributes/status =="
cat -n pages/voting/[poll].tsx | sed -n '180,430p'Repository: livepeer/explorer Length of output: 32155 🌐 Web query:
💡 Result: In the Livepeer subgraph schema, the Poll entity is defined with an ID field of type ID! [1]. When querying individual entities in a GraphQL subgraph, you can typically retrieve a specific entity by its ID using the singular form of the entity name as a query field (e.g., poll(id: $id): Poll) [2][3]. Since the Poll entity's id field is marked as non-nullable (ID!) [1], the query input for retrieving a single poll by its ID requires an ID argument. While the schema definition itself specifies the ID field's requirements, the generated GraphQL schema for The Graph subgraphs includes top-level query fields for each entity, which natively support fetching by the entity's ID [1][2]. If you are writing a query to fetch a specific poll, you would structure it as follows: query GetPoll($id: String!) { poll(id: $id) { id proposal endBlock quorum quota tally { id } } } In this structure, the id argument is required to identify the specific Poll entity [1][2]. If you are encountering issues where the id argument appears to be optional or missing in certain documentation or generated types, ensure that your client-side GraphQL generator (e.g., Apollo Client) is correctly pointing to the latest subgraph schema, as entity-specific query fields for objects with ID types are standard for subgraphs [2][3]. Citations:
🌐 Web query:
💡 Result: In The Graph, a singular entity query (e.g., entity(id: "123")) returns a standard GraphQL response where the Citations:
🌐 Web query:
💡 Result: The file apollo/subgraph.ts in the livepeer/explorer repository is an auto-generated file containing Apollo Client types and hooks derived from GraphQL operations [1][2]. It is not a library-provided file but rather a product of code generation, typically using a tool like GraphQL Code Generator [1]. In this context, usePollQuery is a generated React hook that corresponds to a GraphQL query defined (usually in a.graphql file) within the project [2]. When you define a query named Poll (e.g., in a file like queries/poll.graphql), the code generation process automatically creates a corresponding React hook named usePollQuery [2]. To work with poll data via this hook: 1. Identification: The hook is generated based on the name of the operation in your.graphql files. If your operation is named query Poll, the generated hook will be usePollQuery [2]. 2. Usage: You can use this hook in your React components to fetch poll data from the subgraph [2]. It returns an object containing the data, loading state, error state, and other standard Apollo Client hook properties [2]. 3. Generation: Because apollo/subgraph.ts is auto-generated, you should not edit it directly [1]. Instead, update the underlying GraphQL query files (e.g., in the queries/ directory) and re-run your generation command (often configured in codegen.yml) to update the types and hooks [1][2]. If you are trying to access specific poll data, ensure that your GraphQL query explicitly requests the necessary fields (such as poll ID, choiceID, or voter details) and that your codegen configuration is set to output React hooks [2]. Citations:
Guard
🤖 Prompt for AI Agents |
||
| } | ||
|
Comment on lines
91
to
99
|
||
| }; | ||
| init(); | ||
| }, [data, pollId, currentRound?.currentL1Block]); | ||
| }, [data, currentRound?.currentL1Block]); | ||
|
|
||
| // Only 404 on a genuine subgraph error with no manual fallback for this poll. | ||
| if (pollError && !getManualPoll(pollId)) { | ||
| if (pollError) { | ||
| return <FourZeroFour />; | ||
|
Comment on lines
+104
to
105
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "## files"
git ls-files | sed -n '1,120p'
echo
echo "## target outline/size"
wc -l pages/voting/\[poll\].tsx 2>/dev/null || true
ast-grep outline 'pages/voting/[poll].tsx' 2>/dev/null || true
echo
echo "## target lines 1-180"
cat -n 'pages/voting/[poll].tsx' | sed -n '1,180p'
echo
echo "## hunt for FourZeroFour and pollError usages"
rg -n "FourZeroFour|pollError|apolloError|networkError|graphQLErrors|NotFoundError|Poll" . --glob '!node_modules' --glob '!dist' --glob '!build' | sed -n '1,200p'Repository: livepeer/explorer Length of output: 39702 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "## files"
git ls-files | sed -n '1,120p'
echo
echo "## target outline/size"
wc -l 'pages/voting/[poll].tsx' 2>/dev/null || true
ast-grep outline 'pages/voting/[poll].tsx' 2>/dev/null || true
echo
echo "## target lines 1-180"
cat -n 'pages/voting/[poll].tsx' | sed -n '1,180p'
echo
echo "## hunt for FourZeroFour and pollError usages"
rg -n "FourZeroFour|pollError|apolloError|networkError|graphQLErrors|NotFoundError|Poll" . --glob '!node_modules' --glob '!dist' --glob '!build' | sed -n '1,200p'Repository: livepeer/explorer Length of output: 39584 Do not map every Apollo error to 404.
🤖 Prompt for AI Agents |
||
| } | ||
|
Comment on lines
+104
to
106
|
||
|
|
||
|
|
@@ -217,23 +212,6 @@ const Poll = () => { | |
| </Box> | ||
|
|
||
| <Box> | ||
| {isManualPoll(pollData.id) && ( | ||
| <Box | ||
| css={{ | ||
| marginBottom: "$3", | ||
| padding: "$3", | ||
| borderRadius: "$3", | ||
| border: "1px solid $blue5", | ||
| backgroundColor: "$blue2", | ||
| }} | ||
| > | ||
| <Text size="1" css={{ color: "$blue11" }}> | ||
| Live vote counts aren't available for this poll yet — | ||
| the subgraph is still indexing it. The totals below may read | ||
| 0 until indexing catches up. Voting works normally. | ||
| </Text> | ||
| </Box> | ||
| )} | ||
| <Box | ||
| css={{ | ||
| display: "grid", | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Unguarded Apollo query — subgraph failures now propagate unhandled.
getTotalStakeno longer catches failures fromclient.query. With Apollo's defaulterrorPolicy: "none", a network/GraphQL error rejects the promise, and sincegetPollExtendedawaits this with no try/catch either, any subgraph hiccup will now throw through the poll rendering path instead of degrading gracefully (previously logged + returnedundefined). Given that subgraph instability is exactly what motivated the original manual-poll workaround this PR reverts, losing this safety net reintroduces the failure mode it was built to avoid.If reverting to pre-#734 behavior is intentional, worth confirming the team is fine with poll pages failing outright on subgraph errors rather than degrading.
🛡️ Optional fix to restore graceful degradation
const getTotalStake = async (l2BlockNumber?: number | undefined) => { const client = getApollo(); - const protocolResponse = await client.query< - ProtocolByBlockQuery, - ProtocolByBlockQueryVariables - >({ - query: ProtocolByBlockDocument, - variables: l2BlockNumber - ? { - block: { - number: l2BlockNumber, - }, - } - : undefined, - fetchPolicy: "network-only", - }); - - return protocolResponse?.data?.protocol?.totalActiveStake; + try { + const protocolResponse = await client.query< + ProtocolByBlockQuery, + ProtocolByBlockQueryVariables + >({ + query: ProtocolByBlockDocument, + variables: l2BlockNumber + ? { + block: { + number: l2BlockNumber, + }, + } + : undefined, + fetchPolicy: "network-only", + }); + + return protocolResponse?.data?.protocol?.totalActiveStake; + } catch (err) { + console.warn(`Could not fetch total stake: ${err}`); + return undefined; + } };📝 Committable suggestion
🤖 Prompt for AI Agents