Skip to content

🐛 Bug Report: Failed to get the Session object from Future<Session> #65

@patricktslee

Description

@patricktslee

👟 Reproduction steps

Have you experienced the issue on Flutter to run Appwrite "Get Session By ID"? I tried to setup the getSession method on below. But it looks like that it is failed to get the Session object from Future. Please see my below code and debug console message.

  Future<String> getSession(String? sessionID) async {
    _debug(
        "At ${DateTime.now()} getSession($sessionID) => Starting ApiService getSession()");
    String _result = "result";

    try {
      Future result = account!.getSession(sessionId: sessionID!);

      _debug(
          "At ${DateTime.now()} getSession($sessionID) result type is ${result.runtimeType}");
      result.then((response) {
        _debug("getSession($sessionID) response is");
//        _result = response.toString();
        _debug("getSession($sessionID) _result is $_result");
      }).catchError((error) {
        _debug("getSessions() error is ${(error.response)}");
      });
    } on AppwriteException catch (exception, stackTrace) {
      _debug("getSession($sessionID) fail!");
      _debug(stackTrace.toString());
      await Sentry.captureException(
        exception,
        stackTrace: stackTrace,
      );
    }
    _debug(
        "At ${DateTime.now()} getSession($sessionID) => Completed ApiService getSession()");
    return _result;
  }

Debug console message

I/flutter ( 5925): At ApiService class - At 2022-05-30 11:46:21.507695 getSession(6294396a991339db8d84) => Starting ApiService getSession()
I/flutter ( 5925): │ :bulb: At ApiService class - At 2022-05-30 11:46:21.507695 getSession(6294396a991339db8d84) => Starting ApiService getSession()
I/flutter ( 5925): At ApiService class - At 2022-05-30 11:46:21.525700 getSession(6294396a991339db8d84) result type is Future<Session>
I/flutter ( 5925): │ :bulb: At ApiService class - At 2022-05-30 11:46:21.525700 getSession(6294396a991339db8d84) result type is Future<Session>
I/flutter ( 5925): At ApiService class - At 2022-05-30 11:46:21.539364 getSession(6294396a991339db8d84) => Completed ApiService getSession()
I/flutter ( 5925): │ :bulb: At ApiService class - At 2022-05-30 11:46:21.539364 getSession(6294396a991339db8d84) => Completed ApiService getSession()

It can't find the "getSession($sessionID) response is" message in debug console.

I captured the error when the Session is loaded.. It looks like providerAccessTokenExpiry is null and cause the exception throw. As this is the Anonymous User, should the providerAccessTokenExpiry be null?

image

I am using appwrite: ^5.0.0

👍 Expected behavior

Return the Session information

👎 Actual Behavior

Not return Session information

🎲 Appwrite version

Version 2.0.x

💻 Operating system

Windows

🧱 Your Environment

I use the vscode in Windows 11

👀 Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions