Skip to content

Better ownership lint to kill ownership chaos for AI generated codeΒ #63540

@loynoir

Description

@loynoir

πŸ” Search Terms

  • proposal-explicit-resource-management
  • ownership
  • lifetime

βœ… Viability Checklist

⭐ Suggestion

Better ownership lint to kill ownership chaos.

Maybe rust lifetime?

πŸ“ƒ Motivating Example

See

denoland/deno#34953

Typescript should lint below code will crash due to ownership

Deno.serve({}, async (_req) => {
  using file = await Deno.open(new URL(import.meta.url).pathname);
  return new Response(file.readable);
});

denoland/deno#34953 (comment)

Some think

file.readable carries ownership of the file

denoland/deno#34953 (comment)

Some think file.readable does not carries ownership of the file

> file.readable[Symbol.dispose]
undefined

πŸ’» Use Cases

  1. What do you want to use this for?

Better ownership type

  1. What shortcomings exist with current approaches?

TBD

  1. What workarounds are you using in the meantime?

No way.

related

denoland/deno#34931

Simple code leads to server crash due to ownership

Genered by AI.

Simplified for reproduce.

Deno.serve({}, async (_req) => {
  using file = await Deno.open(new URL(import.meta.url).pathname);
  return new Response(file.readable);
});

denoland/deno#34953

How to easy stream file within deno server?


tc39/proposal-explicit-resource-management#274

How does proposal-explicit-resource-management suggest how to easy extend stream file lifetime within server?


#63540

Better ownership lint to kill ownership chaos

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions