OfficeDev / office-js

A repo and NPM package for Office.js, corresponding to a copy of what gets published to the official "evergreen" Office.js CDN, at https://appsforoffice.microsoft.com/lib/1/hosted/office.js.
https://learn.microsoft.com/javascript/api/overview
Other
657 stars 94 forks source link

First request to save custom properties always fails in New Outlook for Windows #4628

Open bogdanst24 opened 1 week ago

bogdanst24 commented 1 week ago

Provide required information needed to triage your issue

Your Environment

Expected behavior

When saving the custom properties (after setting them) for the first time in an event-based add-in (onMessageCompose), the properties are successfully saved

Current behavior

When saved for the first time, the operation throws an internal error image

The error comes after a failed post request to https://outlook.office.com/owa/service.svc?action=SaveExtensionCustomProperties&app=Mail&n=1336

image

Steps to reproduce

  1. Use a manifest that has event-based activation. OnMessageCompose event
  2. Have a set and saveAsync in the implementation

Example:

mailboxItem.loadCustomPropertiesAsync(
          asyncResultCallback(
            (result) => {
              result.set(this.settingName, newValue);
              result.saveAsync(asyncResultCallback(resolve, reject));
            },
            (error) => {
              owaLogEvent(
                'Unknown',
                `Unable to set CustomProperty "${this.settingName}"`,
                error,
              );
              resolve(undefined);
            },
          ),
        );
  1. Open New Outlook for Windows
  2. Create a new message so that the event is triggered

Context

Useful logs

Thank you for taking the time to report an issue. Our triage team will respond to you in less than 72 hours. Normally, response time is <10 hours Monday through Friday. We do not triage on weekends.

Swathy-Mothilal commented 1 week ago

@bogdanst24 We are unable to reproduce the issue. Could you please provide a manifest and a video of the issue so we can investigate it more effectively?

bogdanst24 commented 1 week ago

Probably important to emphasize that it was working for a long time without issues. I can reproduce it with this very basic add-in:

void Office.onReady(() => {});
Office.actions.associate(
  'onMessageComposeHandler',
  (event: Office.AddinCommands.Event) =>
    void onMessageComposeHandler(event),
);
export function onMessageComposeHandler(
  event: Office.AddinCommands.Event,
  contextParameters: WebAddInContextParameters,
) {
  Office.context.mailbox.item?.loadCustomPropertiesAsync((result) => {
    if (result.status === Office.AsyncResultStatus.Failed) {
      console.log('ERROR', result.error);
    }
    const allValues = result.value.get('test');
    console.log('allValues', allValues);

    result.value.set('test', 'testValue');
    result.value.saveAsync((result) => {
      console.log('saveAsync', result);
    });
  });
}

Result: image

Relevant part in the manifest:

 <ExtensionPoint xsi:type="LaunchEvent">
              <LaunchEvents>
                <LaunchEvent Type="OnNewMessageCompose" FunctionName="onMessageComposeHandler" />
                ....
              </LaunchEvents>
</ExtensionPoint>

I can send the full manifest via email, but I find it useless as you won't be test with it.

Later edit: I can reproduce it also by using the simple code from the Script Lab (moving it into an event based one)

bogdanst24 commented 1 week ago

Again, I can only reproduce it in the New Outlook for Windows. image

Swathy-Mothilal commented 1 week ago

@bogdanst24 Based on the details that you have provided, we are still unable to repro the issue. Could you please share your manifest and a video of the issue to understand the issue better?

bogdanst24 commented 1 week ago

Could you please share an email address I can send to?

Swathy-Mothilal commented 1 week ago

@bogdanst24 Please host your manifest in a private repo, and grant access to me!

bogdanst24 commented 1 week ago

Done. You won't be able to log in, but that shouldn't matter as the issue is reproducible before that. Triggering a new email is enough. You should be able to see 3 Post requests ending up with 400 status code

image

Swathy-Mothilal commented 1 week ago

@bogdanst24 We have been able to reproduce the issue. To better understand the problem, could you please confirm if subsequent requests after logging in or saving custom properties again are successful as this seems to be an auth problem.

bogdanst24 commented 1 week ago

To better understand the problem, could you please confirm if subsequent requests after logging in or saving custom properties again are successful

Yes, exactly. What you are seeing now being logged, are some operations we introduced as a workaround. Exactly because, as described also in the title of the issue, only the first one seems to fail. Or, it might be all operations for the first x seconds.

this seems to be an auth problem.

No specific authentication is performed. I think we have been seeing this error in our logs for a long time for some customers (~20%), but we were never able to reproduce it. Now, since 2-3 weeks ago, it is affecting everyone.

Swathy-Mothilal commented 1 week ago

@bogdanst24 Thanks for the clarification. It has been put on our backlog. We, unfortunately, have no timelines to share at this point. Internal tracking id: Eg: Office: 4707994