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

Cryptic "Unexpected end" console output: Improve logging in Recurrence.ts #2916

Open
2 of 7 tasks
claremacrae opened this issue Jun 25, 2024 · 0 comments
Open
2 of 7 tasks
Labels
scope: recurrence Anything to do with recurring/repeating tasks type: bug Something isn't working

Comments

@claremacrae
Copy link
Collaborator

Please check that this issue hasn't been reported before.

  • I searched previous Bug Reports didn't find any similar reports.

Expected Behavior

Any console log output should be meaingful

Current behaviour

I received the following console output from Tasks earlier today on my Mac:

"Unexpected end"

I traced the location to near hte end of this code, built from src/Task/Recurrence.ts:

  static fromText({
    recurrenceRuleText,
    startDate,
    scheduledDate,
    dueDate
  }) {
    try {
      const match = recurrenceRuleText.match(/^([a-zA-Z0-9, !]+?)( when done)?$/i);
      if (match == null) {
        return null;
      }
      const isolatedRuleText = match[1].trim();
      const baseOnToday = match[2] !== void 0;
      const options = RRule.parseText(isolatedRuleText);
      if (options !== null) {
        let referenceDate = null;
        if (dueDate) {
          referenceDate = window.moment(dueDate);
        } else if (scheduledDate) {
          referenceDate = window.moment(scheduledDate);
        } else if (startDate) {
          referenceDate = window.moment(startDate);
        }
        if (!baseOnToday && referenceDate !== null) {
          options.dtstart = window.moment(referenceDate).startOf("day").utc(true).toDate();
        } else {
          options.dtstart = window.moment().startOf("day").utc(true).toDate();
        }
        const rrule = new RRule(options);
        return new Recurrence({
          rrule,
          baseOnToday,
          referenceDate,
          startDate,
          scheduledDate,
          dueDate
        });
      }
    } catch (e) {
      if (e instanceof Error) {
        console.log(e.message); // <<<<<< FROM HERE
      }
    }
    return null;
  }

Steps to reproduce

Unsure, but I expect that it may be written whilst editing the recurrence rule on a task.

Which Operating Systems are you using?

  • Android
  • iPhone/iPad
  • Linux
  • macOS
  • Windows

Obsidian Version

1.6.4

Tasks Plugin Version

7.5.0, local build

Checks

  • I have tried it with all other plugins disabled and the error still occurs

Possible solution

It seems the output from rrule is not enough to give a meaningful message - so the log should be changed to report the text that is being analysed.

@claremacrae claremacrae added type: bug Something isn't working scope: recurrence Anything to do with recurring/repeating tasks labels Jun 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: recurrence Anything to do with recurring/repeating tasks type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant