luckyframework / luckyframework/lucky

Handle current fiber data per request

Open
#1,668 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

clarify api hacktoberfest needs investigation
Dominant language
Crystal
Stars
2.7k
Forks
172
PR merge metrics
No merged PRs in 30d

Description

Related: https://github.com/luckyframework/avram/issues/804

It's not always the case, but it is technically possible for 2 requests to use the same Fiber instance. Breeze also patches Fiber

https://github.com/luckyframework/breeze/blob/52d6e8152121e624dcf4fc2f40d5c50a192586a2/src/charms/fiber.cr#L5

This is used so we can track information per request to store in Breeze.

One nice thing that Athena is doing is creating this object inside of a handler to ensure each request sets that value on the current fiber regardless of if the fiber is the same from the previous request.

https://github.com/athena-framework/athena/blob/fb9d23d6717539f98312188a23de9bec213264bf/src/components/framework/src/athena.cr#L152-L153

I think we should create something similar, and then any time we need to patch Fiber, we would actually just patch this "container" object. Then that would be set in some handler to guarantee it's consistent. Maybe the request id handler could be merged, and then stored on this thing? 🤷‍♂️

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Compare the referenced Breeze implementation in src/charms/fiber.cr with Athena's handler code in src/components/framework/src/athena.cr. Trace Lucky's request-scoped data and request-id handling, then determine how reused Fiber instances should be covered. Done means request data is isolated per request, with tests demonstrating safe behavior when a Fiber is reused.

Written by the indexing model from the issue text.

Assessment

Tech stack
crystal
Domain
backend, web-dev
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.