Programming Kotlin: Difference between SupervisorJob() and supervisorScope (324, 325)

Hi @venkats,

It has been mentioned in the description of ‘Supervisory Job’ title that 2 things as mentioned below result in the same effect - preventing the parent from cancelling when an unhandled exception occurs in one of the children

  1. Passing a SupervisorJob instance to the coroutine
  2. Wrapping the children inside a supervisorScope,

However, the example provided in ‘async/cancellationbidirectional.kts’ does use ‘SupervisorJob()’ in the parent ‘launch’, and parent job fails as mentioned in the book. When I try it, the result is the same: parent job fails, there is no successful 200 response, CancellationException is caught.

Why is that SupervisorJob() instance passage to the coroutine does not result in the desired behaviour? Using supervisorScope() works as expected. Is there any difference in using SupervisorJob() and supervisorScope()?

Please advise.

Thanks,
Harry