Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

Error when trying to register headless task in library

Aberta
#883 0 comentários 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
25/100
Tipo de issue
Bug
Clareza
Precisa de esclarecimento
Status de atividade
Estagnada
Stack de tecnologia
javascript, react-native
Domínio
mobile-dev, tooling

Direção de pesquisa

Comece reproduzindo o problema a partir do repro vinculado e compare os resultados de AppRegistry em example/index.js com os do wrapper da biblioteca. Inspecione como o setup de turbo-module do create-react-native-library resolve o React Native e, em seguida, verifique se o registro de tarefas headless funciona por meio da biblioteca sem instâncias duplicadas do React Native.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

bug
Description

Hi!

I'm trying to create a wrapper around the AppRegistry.registerHeadlessTask function in my library like this:

export function setBackgroundMessageHandler(handler: BackgroundMessageHandler) {
  AppRegistry.registerHeadlessTask('MediaControlsHeadlessTask', () => handler);
}

And this is in the example/index,js:

setBackgroundMessageHandler(require('./src/handler'));

This results in the following errors:

E  Invariant Violation: "MediaControlsExample" has not been registered. This can happen if:
* Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it, and restart it in the current project.
 * A module failed to load due to an error, and `AppRegistry.registerComponent` wasn't called., js engine: hermes

E  ExceptionsManager should be set up after React DevTools to avoid console.error arguments mutation
E  TypeError: property is not writable, js engine: hermes
E  TypeError: Cannot read property 'default' of undefined, js engine: hermes

Calling AppRegistry.registerHeadlessTask in the example/index.js directly works. It seems like AppRegistry points to two react-native instances?! E.g. when printing AppRegistry.getAppKeys(), I get different results in the example/index.js and the library.

Packages
  • create-react-native-library
  • react-native-builder-bob
Selected options

"create-react-native-library": {
"languages": "kotlin-objc",
"type": "turbo-module",
"version": "0.52.0"
}

Link to repro

https://github.com/mbpictures/react-native-media-notification/tree/feat/android-auto-library

Environment

info Fetching system and libraries information...
System:
OS: Windows 11 10.0.26100
CPU: (24) x64 13th Gen Intel(R) Core(TM) i7-13700K
Memory: 3.77 GB / 31.77 GB
Binaries:
Node:
version: 22.16.0
path: C:\Program Files\nodejs\node.EXE
Yarn:
version: 3.6.1
path: ~\AppData\Roaming\npm\yarn.CMD
npm:
version: 8.12.2
path: C:\Program Files\nodejs\npm.CMD
Watchman: Not Found
SDKs:
Android SDK: Not Found
Windows SDK:
AllowAllTrustedApps: Enabled
AllowDevelopmentWithoutDevLicense: Enabled
Versions:
- 10.0.19041.0
- 10.0.22000.0
IDEs:
Android Studio: Not Found
Visual Studio:
- 16.11.35026.282 (Visual Studio Community 2019)
- 17.10.35122.118 (Visual Studio Community 2022)
Languages:
Java: 17.0.9
Ruby:
version: 3.2.3
path: C:\Ruby32-x64\bin\ruby.EXE
npmPackages:
"@react-native-community/cli":
installed: 18.0.0
wanted: 18.0.0
react:
installed: 19.0.0
wanted: 19.0.0
react-native:
installed: 0.79.2
wanted: 0.79.2
react-native-windows: Not Found
npmGlobalPackages:
"react-native": Not Found
Android:
hermesEnabled: true
newArchEnabled: true
iOS:
hermesEnabled: Not found
newArchEnabled: Not found

info React Native v0.81.0 is now available (your project is running on v0.79.2).
info Changelog: https://github.com/facebook/react-native/releases/tag/v0.81.0
info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.79.2&to=0.81.0
info For more info, check out "https://reactnative.dev/docs/upgrading?os=windows".

Linguagem predominante
JavaScript
Estrelas
3.2k
Forks
228
Métricas de merge de PRs
Nenhum PR com merge em 30d

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de callstack/react-native-builder-bob

Todas as issues de callstack/react-native-builder-bob

Issues semelhantes

Mais issues de JavaScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.