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

Itty-Durable sending empty string response causing an "Unhandled Promise Rejection" #31

Open
maurerbot opened this issue Jan 4, 2023 · 1 comment

Comments

@maurerbot
Copy link

I'm using itty durable and manually creating a proxyDurable the following way:

export const initAccountNodeByName = async (
  name: string,
  durableObject: DurableObjectNamespace
) => {
  const proxy = await proxyDurable(durableObject, {
    name: 'account',
    class: Account,
    parse: true,
  })

  const node = proxy.get(name) as Account
  return node
}

Everything works great but in the logs there the following errors occurs.

YN0000: { text: '' }
➤ YN0000:  Trace: 
➤ YN0000::     at Request.json (/Users/adrianmaurer/Code/kubelt/node_modules/undici/lib/fetch/body.js:392:17)
➤ YN0000: :     at runNextTicks (node:internal/process/task_queues:60:5)
➤ YN0000: :     at processImmediate (node:internal/timers:442:9)
➤ YN0000: :     at process.topLevelDomainCallback (node:domain:161:15)
➤ YN0000::     at process.callbackTrampoline (node:internal/async_hooks:128:24)
➤ YN0000: :     at Request.json (/node_modules/@miniflare/core/src/standards/http.ts:333:18)
➤ YN0000:      at withContent (/node_modules/itty-router-extras/middleware/withContent.js:1:132)
➤ YN0000: :     at Object.handle (//node_modules/itty-router/dist/itty-router.min.js:1:590)

note: this does not break the app but it's strange that the proxy object is returning an empty string response.

Here is the DO:

export default class Account extends createDurable({
  autoReturn: true,
  autoPersist: false,
}) {
  declare state: Node.IttyDurableObjectState<Environment>

  async getProfile(): Promise<Profile | null> {
    const stored = await this.state.storage.get<Profile>('profile')
    return stored || null
  }

  async setProfile(profile: Profile): Promise<void> {
    return this.state.storage.put('profile', profile)
  }
}
@maurerbot
Copy link
Author

One more note: Logging the responses for the DO never yields an empty string

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant