Back

Week 24 - 2019

The weeknote for 6/10 - 6/16.

OSS

denoland/deno

🦕 Deno is a new JavaScript and TypeScript runtime.

$ deno install file_server https://deno.land/std/http/file_server.ts --allow-net --allow-read

MyProject

kt3k/moneybit-app

💰 Moneybit is an open source mobile accounting app.

Job

goroutine leaks

func Foo() {
  ...
  for _, item := range list {
    go func(item Item) {
      c <- doNetworkJob(item)
    }(item)
  }

  for range list {
    err <- c
    if err != nil {
      return err
    }
  }
  ...
}

I supposed this worked like something JavaScript equivalent of:

function foo() {
  ...
  try {
    await Promise.race(list.map(doNetworkJob))
  } catch (e) {
    throw e
  }
  ...
}

But it actually isn't. This leaks the gorouines after leaving the function Foo because the channel c looses the receiver and c <- doNetworkJob(item) blocks forever!

Movie

MIB: International


Back

Edit this page

revision: 90a8f3f