REST resource state persisting between job/request executions within the same thread
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 35/100
Rechercherichtung
Beginne damit, die Behandlung des Zustands von REST-Ressourcen in lib/shopify_api/rest/base.rb zu lesen, insbesondere die verlinkten Zeilen 125-153. Ermittle, wie der Zustand von Klasseninstanzen über Requests oder Jobs hinweg bestehen bleibt, und definiere dann einen Rücksetz- oder Isolationspunkt, damit der Zustand aus einer früheren Ausführung, einschließlich eines anderen Shops, nicht vor einem neuen Request wiederverwendet wird.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Issue summary
By default, rails applications in production will not reload constants & classes between requests or
between execution of background jobs. This means that certain data stored within class instance variables on the REST
resources (see the base resource here)
will not be reset when a given thread completes processing a request or job, and begins to process another.
To illistrate where this could be an issue, consider a simple class that might be used throughout an application to
fetch product information for a Shop:
class FetchProducts
class << self
def call
return if rate_limit_reached?
ShopifyAPI::Product.all
end
private
def rate_limit_reached?
limits = ShopifyAPI::Product.api_call_limit
return false unless limits.is_a?(Hash) && limits[:request_count] >= limits[:bucket_size]
true
end
end
end
If no prior Product API calls have been made within the context of current job or request, it would be reasonable
to expect ShopifyAPI::Product.api_call_limit to be nil since we haven't made a request yet, and therefore there have
not received a response with any rate limiting headers.
However since api_call_limit is stored within a class instance variable within the ShopifyAPI::Product class,
if the current thread has previously processed a separate request or job that used the ShopifyAPI::Product
class to fetch products, then the response headers from that prior request will stil be present in the class.
It's entirely possible that this prior job or request pertained to an entirely separate shop, and thus the stored
rate limit headers would not be applicable within our current job / request.
The implication of this, is that it's not safe to check values stored in the class instance state of the REST resources until after a request has been made through that same class.
- Vorherrschende Sprache
- Ruby
- Sterne
- 1.1k
- Forks
- 487
- Ø Merge
- 1 T. 2 Std.
- Gemergte PRs (30 T.)
- 2
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus Shopify/shopify-api-ruby
-
devtools-gardener
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
Shopify/shopify-api-ruby#1456 · 3 Reaktionen ·
-
Allow configuring open/read timeouts for API requestsEvtl. vergeben @fluke hat das vor 19 Tagen übernommen. Offendevtools-gardener
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 35/100
Shopify/shopify-api-ruby#1466 · 1 Kommentar ·
-
automated
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 35/100
Shopify/shopify-api-ruby#1465 ·
-
oj dependency breaks support for JRubyEvtl. vergeben @najibna hat das vor 32 Tagen übernommen. Offendevtools-gardener
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 67/100
Shopify/shopify-api-ruby#1461 · 1 Kommentar ·
-
automated
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
Shopify/shopify-api-ruby#1460 ·
Alle Issues in Shopify/shopify-api-ruby
Ähnliche Issues
-
Bug: Assistant replies lose the space before numbers ("Oct7", "as of10-22-2026") with OpenAI modelsOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
we-promise/sure#4441 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
lugassawan/swe-workbench#823 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Admin user page looks up a Tag for every instance-scoped role (`Role#resource_name`)Evtl. vergeben @pkfrank hat das heute übernommen. Offenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
forem/forem#24083 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
rubyjs/mini_racer#449 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
samvera/hyku#3446 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag