aws / aws/jsii

Callback into behavioral interface implementation fails from async context

Open
#3,917 0 comments 0 reactions 1 assignee Claimed by @mrgrain View on GitHub
bug p2
Dominant language
TypeScript
Stars
2.9k
Forks
267
Avg merge
1d 25m
Merged PRs (30d)
14

Description

### Describe the bug

Given the following code:
```python
#!/usr/bin/env python3
import builtins
import typing
import jsii
import aws_cdk as cdk
import aws_cdk.aws_sqs as sqs
from aws_cdk.cli_lib_alpha import AwsCdkCli, ICloudAssemblyDirectoryProducer

@jsii.implements(ICloudAssemblyDirectoryProducer)
class CliProducer:
def produce(self, context: typing.Mapping[builtins.str, typing.Any]) -> builtins.str:
app = cdk.App()
stack = cdk.Stack(app, 'Default')
sqs.Queue(stack, 'Queue')
return app.synth().directory

cli = AwsCdkCli.from_cloud_assembly_directory_producer(producer=CliProducer())
cli.list()
```

### Current Behavior

jsii fails with
```
File "/Users/abc/.pyenv/versions/3.10.5/lib/python3.10/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Exception ignored in atexit callback: >
Traceback (most recent call last):
File "/Users/abc/code/scratchpad/cli-lib/python/.venv/lib/python3.10/site-packages/jsii/_kernel/providers/process.py", line 295, in stop
self._process.stdin.close()
BrokenPipeError: [Errno 32] Broken pipe
```

### Reproduction Steps

Using these `requirements.txt`:
```
aws-cdk-lib==2.61.0
constructs>=10.0.0,<11.0.0
pytest==6.2.5
black>=22.6.0
aws-cdk.cli-lib-alpha==2.61.0a0
```

### Possible Solution

_No response_

### Additional Information/Context

Last part of `JSII_DEBUG` just before the error:

```
[@jsii/kernel] callbacks
< {"ok":{"callbacks":[]}}
> {"promiseid":"jsii::promise::20000","api":"end"}
[@jsii/kernel] end jsii::promise::20000
waiting for promise to be fulfilled
[@jsii/kernel] invoke async method override { method: 'produce', property: null, cookie: 'produce' }
[@jsii/kernel] deserialize {
'aws:cdk:enable-path-metadata': true,
'aws:cdk:enable-asset-metadata': true,
'aws:cdk:version-reporting': true,
'aws:cdk:bundling-stacks': []
} [
{
serializationClass: 'Map',
typeRef: { name: 'context', type: [Object] }
}
]
[@jsii/kernel] deserialize true [ { serializationClass: 'Any', typeRef: { type: [Object] } } ]
[@jsii/kernel] ANY is a Scalar
[@jsii/kernel] deserialize true [ { serializationClass: 'Any', typeRef: { type: [Object] } } ]
[@jsii/kernel] ANY is a Scalar
[@jsii/kernel] deserialize true [ { serializationClass: 'Any', typeRef: { type: [Object] } } ]
[@jsii/kernel] ANY is a Scalar
[@jsii/kernel] deserialize [] [ { serializationClass: 'Any', typeRef: { type: [Object] } } ]
[@jsii/kernel] ANY is an Array
[@jsii/kernel] adding callback to queue jsii::callback::20001
```

### SDK version used

jsii-1.73.0

### Environment details (OS name and version, etc.)

MacOS

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.