typelevel / typelevel/feral

Should the return type of init really be a Resource?

Open
#300 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Scala
Stars
195
Forks
53
PR merge metrics
No merged PRs in 30d

Description

I noticed in IOSetup, the finalizer for the Resource is never run (the finalizer returned from allocated is discarded). I think that's a reasonable thing to do, but it makes the typesignature of IOLambda.Simple#init a little disingenuous:

def init: Resource[IO, Init]

The user goes to the trouble of building a Resource, and probably assumes everything will be cleaned up when the Lambda instance is terminated, when in fact the finalizer is dropped on the floor.

Maybe def init: IO[Init] would be less misleading? Or at least a comment explaining that the finalizer won't be run would be helpful.

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

Start by inspecting IOSetup and the IOLambda.Simple#init signature. Trace how the Resource returned by init is allocated and whether its finalizer is retained; then resolve whether the API should return IO[Init] or document the discarded finalizer. Done means the lifecycle behavior and public type are consistent.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
cloud
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.