Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Dart/quickstarts/callable-functions-streaming/bin/server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ Future<dynamic> weatherForecastApi(num lat, num lng) async {
return jsonDecode(forecastResp.body);
}

void main(List<String> args) async {
await fireUp(args, (firebase) {
void main() {
runFunctions((firebase) {
Comment on lines +49 to +50
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The update to firebase_functions 0.6.0 introduces breaking changes that are not fully addressed in the function handlers:

  1. onCall Signature: The handler now takes a single CallableRequest argument. The response object is now a property of the request object. You must update line 52 to (request) async { and line 76 to await request.response.sendChunk(result);.
  2. CallableResult Removal: This class has been removed in 0.6.0. You should return the result directly (e.g., return await Future.wait(allRequests); on line 86).
  3. Async Main: It is recommended to await runFunctions to ensure the entry point correctly handles the server's lifecycle.
Suggested change
void main() {
runFunctions((firebase) {
void main() async {
await runFunctions((firebase) {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. That's not true and I verified that this code still works in the emulator. See https://pub.dev/documentation/firebase_functions/latest/firebase_functions/HttpsNamespace/onCall.html
  2. That's not true, see https://pub.dev/documentation/firebase_functions/latest/firebase_functions/CallableResult-class.html
  3. Adding await is probably a stylistic improvement but it won't actually change the behavior of the application and it won't match our examples.

// [START streaming-callable]
firebase.https.onCall(name: 'getForecast', (request, response) async {
final data = request.data as Map<String, Object?>?;
Expand Down
2 changes: 1 addition & 1 deletion Dart/quickstarts/callable-functions-streaming/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ environment:
sdk: ^3.11.0

dependencies:
firebase_functions: ^0.5.0
firebase_functions: ^0.6.0
http: ^1.2.0

dev_dependencies:
Expand Down
4 changes: 2 additions & 2 deletions Dart/quickstarts/callable-functions/bin/server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import 'package:firebase_functions/firebase_functions.dart';
// [END imports]

void main(List<String> args) async {
await fireUp(args, (firebase) {
void main() {
runFunctions((firebase) {
Comment on lines +20 to +21
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The update to firebase_functions 0.6.0 requires updates to the onCall handler signature and return type:

  1. onCall Signature: The handler on line 25 should be updated to take only one argument: (request) async {. The response argument is no longer passed separately.
  2. CallableResult Removal: The CallableResult wrapper on line 60 should be removed, and the map should be returned directly. Remember to also remove the closing parenthesis on line 65.
  3. Async Main: Consider using await runFunctions for better lifecycle management.
Suggested change
void main() {
runFunctions((firebase) {
void main() async {
await runFunctions((firebase) {

// [START allAdd]
// [START addFunctionTrigger]
// Adds two numbers to each other.
Expand Down
2 changes: 1 addition & 1 deletion Dart/quickstarts/callable-functions/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ environment:
sdk: ^3.11.0

dependencies:
firebase_functions: ^0.5.0
firebase_functions: ^0.6.0

dev_dependencies:
build_runner: ^2.10.5
Expand Down
4 changes: 2 additions & 2 deletions Dart/quickstarts/https-time-server/bin/server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ import 'package:intl/intl.dart';
/// -d '{"format": "MMMM d yyyy, h:mm:ss a"}' /
/// https://date-<random-hash>.<region>.run.app
// [START dartHttpTrigger]
void main(List<String> args) async {
await fireUp(args, (firebase) {
void main() {
runFunctions((firebase) {
Comment on lines +41 to +42
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

It is recommended to await runFunctions to ensure the entry point handles the server's future correctly, even if the event loop keeps the process alive.

Suggested change
void main() {
runFunctions((firebase) {
void main() async {
await runFunctions((firebase) {

firebase.https.onRequest(name: 'date', (request) async {
// [END dartHttpTrigger]

Expand Down
2 changes: 1 addition & 1 deletion Dart/quickstarts/https-time-server/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ environment:
sdk: ^3.11.0

dependencies:
firebase_functions: ^0.5.0
firebase_functions: ^0.6.0
firebase_admin_sdk: ^0.5.0
google_cloud_firestore: ^0.5.0
intl: ^0.20.2
Expand Down
4 changes: 2 additions & 2 deletions Dart/quickstarts/resize-image/bin/server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ final defaultWidth = defineInt(
ParamOptions<int>(defaultValue: 300),
);

void main(List<String> args) async {
await fireUp(args, (firebase) {
void main() {
runFunctions((firebase) {
Comment on lines +13 to +14
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

It is recommended to await runFunctions to ensure the entry point handles the server's future correctly.

Suggested change
void main() {
runFunctions((firebase) {
void main() async {
await runFunctions((firebase) {

/// An https function that resizes images in Cloud Storage.
/// It creates a separate Storage folder to cache stored images
/// so that it does not need to resize an image twice.
Expand Down
2 changes: 1 addition & 1 deletion Dart/quickstarts/resize-image/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ environment:
dependencies:
image: ^4.8.0
path: ^1.9.1
firebase_functions: ^0.5.0
firebase_functions: ^0.6.0
intl: ^0.20.2

dev_dependencies:
Expand Down
Loading