Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove duplication / improve organization on "context" properties #204

Closed
mhoeger opened this issue Apr 30, 2019 · 6 comments
Closed

Remove duplication / improve organization on "context" properties #204

mhoeger opened this issue Apr 30, 2019 · 6 comments
Labels
breaking enhancement P2 v4 model 🚀 Related to the new V4 programming model
Milestone

Comments

@mhoeger
Copy link
Contributor

mhoeger commented Apr 30, 2019

Originally posted here: Azure/azure-functions-host#4335
In the above issue, it was expected that context.bindings should include output binding names as well as input/trigger binding data. Although we could add output binding names to context.bindings, this issue is to track improvements around the organization and duplication of input and output binding data.

This issue tracks future breaking changes to the context object's properties

@JamieMagee as FYI. If you could also let us know what your expectations around output bindings were, and what confused you the most, it would be helpful!

@JamieMagee
Copy link

Thanks for following up with this. This doesn't necessarily need to be a breaking change right now. Updating the documentation you linked to change:

Returns a named object that contains all your input and output data

to

Returns a named object that contains all your input and trigger data

Would have saved me some time 😄

@mhoeger
Copy link
Contributor Author

mhoeger commented Apr 30, 2019

@JamieMagee - omg... haha thanks, fixing now :)

@fabiocav fabiocav added this to the Triaged milestone Oct 11, 2019
This was referenced Nov 19, 2019
@mhoeger mhoeger removed the 3.x label Mar 30, 2021
@mhoeger
Copy link
Contributor Author

mhoeger commented Mar 30, 2021

Much duplication was removed on the data passing layer but not on the "context" object itself - worth considering for V4, but for V3 we tended towards limiting breaking changes.

@ejizba ejizba removed this from the Triaged milestone Nov 15, 2021
@ejizba ejizba added this to the Backlog Candidates milestone Jan 28, 2022
@ejizba
Copy link
Contributor

ejizba commented Jan 28, 2022

This is likely something we can address in #480

@ejizba ejizba added the v4 model 🚀 Related to the new V4 programming model label Mar 21, 2022
@ejizba
Copy link
Contributor

ejizba commented Jun 14, 2022

More feedback on why we need to simplify context in relation to unit testing:

Azure function handler expects context object passed as the first parameter. It encapsulates request and response objects as well as information about function bindings. Normally it's prepared by the Azure runtime but in tests, we need to craft it ourselves. There are a lot of nested objects and duplicated bits of data in the context object so assembling it manually can be tedious. Luckily there's a carefully made stub-azure-function-context module which helps with stubbing the context.

https://www.maxivanov.io/unit-testing-azure-function-with-jest-typescript/

ejizba added a commit to Azure/azure-functions-nodejs-library that referenced this issue Aug 19, 2022
Remove backwards compat sys data
Rename bindingMetadata to triggerMetadata
Remove executionContext and move functionName/retryContext up a level
Remove bindingDefinitions because users will define it in code

Related to Azure/azure-functions-nodejs-worker#204
@ejizba
Copy link
Contributor

ejizba commented Aug 24, 2022

Minor details might still change, but overall this was addressed in the following commits as a part of the new programming model:

Azure/azure-functions-nodejs-library@0aac975
Azure/azure-functions-nodejs-library@15e0d38
Azure/azure-functions-nodejs-library@a5d678e
Azure/azure-functions-nodejs-library@9e6a842
Azure/azure-functions-nodejs-library@068dcf4

I've started a doc here with more information: https://aka.ms/AzFuncNodeV4

@ejizba ejizba closed this as completed Aug 24, 2022
ejizba added a commit to Azure/azure-functions-nodejs-library that referenced this issue Aug 25, 2022
Main points:
- We don't want `toCamelCase` to call `fromRpcTypedData` because it traverses an entire object recursively and only the top level objects should be RpcTypedData
- We will remove triggerMetadata from http/timer triggers. That information is best found on the request/timer objects instead

Related to all of these bugs:
Azure/azure-functions-nodejs-worker#607
Azure/azure-functions-nodejs-worker#274
Azure/azure-functions-nodejs-worker#204
Azure/azure-functions-nodejs-worker#388
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking enhancement P2 v4 model 🚀 Related to the new V4 programming model
Projects
None yet
Development

No branches or pull requests

4 participants